diff options
Diffstat (limited to 'plugins/chatbot.py')
-rwxr-xr-x | plugins/chatbot.py | 24 |
1 files changed, 11 insertions, 13 deletions
diff --git a/plugins/chatbot.py b/plugins/chatbot.py index e26928d..e52bb0f 100755 --- a/plugins/chatbot.py +++ b/plugins/chatbot.py @@ -30,18 +30,16 @@ def answer_random(nick, message, is_whisper, answers): mapserv.cmsg_chat_message(resp) def answer(nick, message, is_whisper): - try: - for regex, action in commands.iteritems(): - match = regex.match(message) - if match: - if isinstance(action, types.ListType): - answer_random(nick, message, is_whisper, action) - elif isinstance(action, types.FunctionType): - action(nick, message, is_whisper, match) - else: - raise ValueError("must be either list or function") - except: - answer_random(nick, message, is_whisper, action) + + for regex, action in commands.iteritems(): + match = regex.match(message) + if match: + if isinstance(action, types.ListType): + answer_random(nick, message, is_whisper, action) + elif isinstance(action, types.FunctionType): + action(nick, message, is_whisper, match) + else: + answer_random(nick, message, is_whisper, action) @extends('smsg_being_chat') def being_chat(data): @@ -68,4 +66,4 @@ def remove_command(cmd): def init(config): add_command('!info', answer_info) - add_command('!random', ['asd', 'Ciao!']) + # ~ add_command('!random', ['asd', 'Ciao!']) |