Try this:
code:
unction OnEvent_ChatWndSendMessage(ChatWnd, Message)
{
if(Message.substr(0, 5) == '#test'){
return 'a message';
}
if(Message.substr(0, 5) == '#info'){
return Message.replace('a messeage');
}
}
Though there seems to be missing parameters on your replace function...
As for the menus, they can either be created dynamically using the script files or statically using the SciptInfo.xml file.