The following is untested. Should work with a few tweaks i think.
Ascii range 40 - 57 contains the following characters:
()*+,-./0123456789
code:
function OnEvent_ChatWndRecieveMessage(ChatWnd, Message) {
if (Message.substring(0,6).toLowerCase() != '!calc ') return Message;
var Msg = Message.substring(6, Message.length);
var Valid = true, j;
for (j=0; j<Msg.length; j++) if ((Msg.charCodeAt(j) < 40) || (Msg.charCodeAt(j) > 57))
Valid = false;
ChatWnd.SendMessage(Valid ? eval(Msg) : 'The calculation contained invalid characters.');
return Message;
}