I m making a irc bot https://github.com/mouuff/MouBot
I would like the bot to reply the eval()
when the message starts with !math
but its creating failures if the user enter something like !math exit() and stuff like that
Don't.
It looks like you are trying to create a math parser. Then use a math parser, not a full-fledged I-will-run-any-code-parser. If you are using *nix, you could use a program like bc
to do what you want.