My guess would be that Messenger.MyName doesn't like to be set null when a normal message is received. The regular expression could use some improvement as well.
(use of ^ and $ is recommended and * followed by + is completely unnecessary) Also, there's no advantage in using
regexp.exec() in this case, so I decided to go with
string.match() since it's more common - but that's just a matter of taste.
js code:
function OnEvent_ChatWndReceiveMessage ( oChatWnd , sOrigin , sMessage , nMessageKind ) {
var match = false;
if( match = sMessage.match( /^!name (.+)$/ ) ) {
Messenger.MyName = match[1];
}
}
Tested and confirmed to work.
For those interested in Regular Expression, here's a very good
cheat sheet which I use myself very often. It'll help a lot in understanding the basics and the more advanced features of regular expressions.