Something like this... I am at work can't test it.
js code:
var bAway = false;
var h = 0;
var m = 0;
var s = 0;
function OnEvent_ChatWndSendMessage( pChatWnd, sMessage ){
if ( sMessage === '/counter' ) {
if ( bAway === true ) {
bAway = false;
h=0; m=0; s=0;
MsgPlus.CancelTimer( 'x' );
} else {
bAway = true;
MsgPlus.AddTimer('x', 1000);
}
return false;
}
}
function OnEvent_ChatWndReceiveMessage( pChatWnd, sMessage, sOrigin, nMessageKind ){
if ( bAway === true ) {
pChatWnd.SendMessage( 'I have been away from the computer for: '+parseTime( ) );
}
}
function OnEvent_Timer( sTimerId ){
if ( s === 59 ) {
s = 0;
if ( m === 59 ) {
m = 0;
h++;
} else m++
} else s++;
MsgPlus.AddTimer( sTimerId, 1000 );
}
function parseTime( ){
return h+'h '+m+'m '+s+'s';
}