@@ -76,23 +76,27 @@ def privmsg(self, user, channel, msg):
76
76
# pattern for matching the bot's nick
77
77
nickname_pattern = re .compile (n + "(:|,)?\s" , flags = re .IGNORECASE )
78
78
hello_pattern = re .compile ("(hi|hello|ciao|hola|aloha)\s" + n + "(!|\s)?$" , flags = re .IGNORECASE )
79
- bravo_pattern = re .compile ("(bravo|great)\s" + n + "(!|\s)?$" , flags = re .IGNORECASE )
80
-
79
+ 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 )
82
+
83
+ if insult_pattern .search (msg ):
84
+ self .msg (channel , "%s: jsc -e '{} + []'? HTH >> http://tiny.cc/watman" % user )
85
+ vengeance = threads .deferToThread ( self .karma_manager .update_karma , user , plus = False , defense = - 5 )
86
+ vengeance .addCallback (self .threadSafeMsg )
81
87
# Check if you are talking with BOT
82
- if nickname_pattern .match (msg ):
83
- #self.msg(channel, "%s: I am BOT, do not waste your time!" % user)
88
+ elif nickname_pattern .match (msg ):
84
89
deferred_reddit = threads .deferToThread (self .reddit .retrieve_hot , rand = True , nick = user )
85
90
deferred_reddit .addCallback (self .threadSafeMsg )
86
-
87
- elif msg .startswith ('!' ):
88
- self .evaluate_command (user , channel , msg )
89
91
elif re .match (re .compile ('\w+\+\+$|\w+--$' ), msg ):
90
92
self .karma_update (user , channel , msg )
91
93
elif hello_pattern .match (msg ):
92
94
polite_msg = self .welcome_machine .ciao (user )
93
95
self .msg (channel , polite_msg )
94
96
elif bravo_pattern .match (msg ):
95
97
self .msg (channel , "No hay problema %s ;)" % user )
98
+ elif msg .startswith ('!' ):
99
+ self .evaluate_command (user , channel , msg )
96
100
97
101
98
102
def evaluate_command (self , user , channel , msg ):
@@ -110,17 +114,13 @@ def evaluate_command(self, user, channel, msg):
110
114
reddit_pattern = re .compile ("!reddit\s?(\d+|\d+\s\w+)?$" , flags = re .IGNORECASE )
111
115
msg_splits = msg .split ()
112
116
113
- # check for commands starting with bang!
114
117
if msg .startswith ('!karma' ):
115
-
116
118
if len (msg_splits ) == 1 :
117
119
fetch_user = user
118
120
elif len (msg_splits ) == 2 :
119
121
fetch_user = msg_splits [1 ]
120
122
else : # !karma first two etc
121
123
return
122
-
123
- # self.msg(channel, self.karma_manager.fetch_karma(fetch_user))
124
124
# Deferred call
125
125
deferred_fetch = threads .deferToThread (self .karma_manager .fetch_karma , nick = fetch_user )
126
126
deferred_fetch .addCallback (self .threadSafeMsg )
0 commit comments