summaryrefslogtreecommitdiff
path: root/plugins/chatbot.py
diff options
context:
space:
mode:
authorLivio Recchia <recchialivio@libero.it>2020-04-06 18:50:26 +0000
committerLivio Recchia <recchialivio@libero.it>2020-04-06 18:50:26 +0000
commit076d5f3cdde1f21c6ff75962ae3f6ac0e5a5c303 (patch)
tree49b37cd6d91b426d7eef5bfc31171751e9d3b8d2 /plugins/chatbot.py
parent752e30ec7b044aee96d8f8e15d32aba81b7dde0e (diff)
parentf7b7ec66d47369e735c297372a1956038d9eed39 (diff)
downloadmanachat-076d5f3cdde1f21c6ff75962ae3f6ac0e5a5c303.tar.gz
manachat-076d5f3cdde1f21c6ff75962ae3f6ac0e5a5c303.tar.bz2
manachat-076d5f3cdde1f21c6ff75962ae3f6ac0e5a5c303.tar.xz
manachat-076d5f3cdde1f21c6ff75962ae3f6ac0e5a5c303.zip
Merge branch 'master' into 'jak1/structuring_test'jak1/structuring_test
# Conflicts: # plugins/manaboy.py
Diffstat (limited to 'plugins/chatbot.py')
-rwxr-xr-xplugins/chatbot.py24
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!'])