]> jfr.im git - erebus.git/commitdiff
allow to address bot by nick
authorzonidjan <redacted>
Thu, 23 May 2019 15:32:41 +0000 (10:32 -0500)
committerzonidjan <redacted>
Thu, 23 May 2019 15:32:41 +0000 (10:32 -0500)
bot.py

diff --git a/bot.py b/bot.py
index d56be6f94e9bcf50229766494c0f9dc23a605919..1f8c710157444eb7038ac5918caeee6fc14db48f 100644 (file)
--- a/bot.py
+++ b/bot.py
@@ -287,19 +287,20 @@ class Bot(object):
                if triggerused: msg = msg[len(self.parent.trigger):]
                pieces = msg.split()
 
+               if len(pieces) == 0:
+                       return
+
                if target != self.nick: # message was sent to a channel
                        try:
-                               if msg.startswith('*'): # message may be addressed to bot by "*BOTNICK" trigger?
-                                       if pieces[0][1:].lower() == self.nick.lower():
-                                               pieces.pop(0) # command actually starts with next word
-                                               msg = ' '.join(pieces) # command actually starts with next word
-                                               triggerused = True
+                               if pieces[0][:-1].lower() == self.nick.lower() and (pieces[0][-1] == ":" or pieces[0][-1] == ","):
+                                       pieces.pop(0) # command actually starts with next word
+                                       if len(pieces) == 0: # is there still anything left?
+                                               return
+                                       msg = ' '.join(pieces)
+                                       triggerused = True
                        except IndexError:
                                return # "message" is empty
 
-               if len(pieces) == 0:
-                       return
-
                if len(pieces) > 1:
                        chanword = pieces[1]
                        if chanword.startswith('#'):