Skip to content

Commit 30e564f

Browse files
committed
Fixed !karma. TODO catch "insult pattern".
modified: bot_core/irc_bot.py
1 parent 6728298 commit 30e564f

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

bot_core/irc_bot.py

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,29 @@ def privmsg(self, user, channel, msg):
7676
# pattern for matching the bot's nick
7777
nickname_pattern = re.compile(n + "(:|,)?\s", flags=re.IGNORECASE)
7878
hello_pattern = re.compile("(hi|hello|ciao|hola|aloha)\s" + n + "(!|\s)?$", flags=re.IGNORECASE)
79+
goodbye_pattern = re.compile("(goodbye|bye|see you|see ya|see u)\s" + n + "(!|\s)?$", flags=re.IGNORECASE)
7980
bravo_pattern = re.compile("(bravo|great|good)\s" + n + "(!|\s)?$", flags=re.IGNORECASE)
80-
ins = "([sf]uc|vaff|bastar|pezzo di m|coglio)"
81-
insult_pattern = re.compile( ins+"(.*)"+n, re.IGNORECASE)
8281

83-
if insult_pattern.search(msg):
84-
self.msg(channel, "%s: jsc -e '{} + []'? HTH >> http://tiny.cc/watman" % user)
85-
vengeance = threads.deferToThread( self.data_manager.update_karma, user, plus=False, defense=-5 )
86-
vengeance.addCallback(self.threadSafeMsg)
82+
# TODO (sentenza) fix this check
83+
#ins = "([sf]uc|vaff|bastar|pezzo di m|coglio)"
84+
#insult_pattern = re.compile( ins+"(.*)"+n, re.IGNORECASE)
85+
86+
#if insult_pattern.search(msg):
87+
# self.msg(channel, "%s: jsc -e '{} + []'? HTH >> http://tiny.cc/watman" % user)
88+
# vengeance = threads.deferToThread( self.data_manager.update_karma, user, plus=False, defense=-5 )
89+
# vengeance.addCallback(self.threadSafeMsg)
90+
8791
# Check if you are talking with BOT
88-
elif nickname_pattern.match(msg):
92+
if nickname_pattern.match(msg):
8993
deferred_reddit = threads.deferToThread(self.reddit.retrieve_hot, rand=True, nick=user)
9094
deferred_reddit.addCallback(self.threadSafeMsg)
9195
elif re.match(re.compile('[\w`]+\+\+$|[\w`]+--$', re.I), msg):
9296
self.karma_update(user, channel, msg)
9397
elif hello_pattern.match(msg):
9498
polite_msg = self.welcome_machine.ciao(user)
9599
self.msg(channel, polite_msg)
100+
elif goodbye_pattern.match(msg):
101+
self.msg(channel, "Hasta la vista, %s." % user)
96102
elif bravo_pattern.match(msg):
97103
self.msg(channel, "No hay problema %s ;)" % user)
98104
elif msg.startswith('!'):
@@ -116,7 +122,7 @@ def evaluate_command(self, user, channel, msg):
116122

117123
if re.match(re.compile("!(karma|k)(\s)*", re.IGNORECASE), msg):
118124
if len(msg_splits) == 1:
119-
fetch_word = user
125+
fetch_word = user.lower()
120126
elif len(msg_splits) == 2:
121127
fetch_word = msg_splits[1].lower()
122128
else: # !karma first two etc

0 commit comments

Comments
 (0)