js code:
var old_status = "";
function OnEvent_ChatWndCreated(){
if(Messenger.CurrentChats.Count > 0){
if(old_status === "") old_status = Messenger.MyStatus;
Messenger.MyStatus = STATUS_BUSY;
}
}
function OnEvent_ChatWndDestroyed(){
if(Messenger.CurrentChats.Count === 0){
Messenger.MyStatus = old_status
old_status = "";
}
}
Untested, but should work from what I can tell.