]> kaliko git repositories - sid.git/commitdiff
Do not answer messages from unseen
authorkaliko <kaliko@azylum.org>
Wed, 13 May 2020 13:49:15 +0000 (15:49 +0200)
committerkaliko <kaliko@azylum.org>
Wed, 13 May 2020 13:49:15 +0000 (15:49 +0200)
The bot only answers to contact it received presence from and to groupchat messages.

sid/sid.py

index d412ac4ad65d362b0427cdafb35a2f6485e8e7bd..a62c7e46fd14fd7c0d61875cad45f8b650da802b 100644 (file)
@@ -123,9 +123,11 @@ class MUCBot(slixmpp.ClientXMPP):
         body = msg['body'].strip()
         if not body.startswith(MUCBot.prefix):
             return
-        if msg['from'] not in self.__seen:
-            self.log.warning('Will not handle message from unseen jid: %s', msg['from'])
-            #return
+        self.log.debug(msg['from'])
+        if msg['from'] not in self.__seen and msg['type'] == 'chat':
+            self.log.warning('Will not handle direct message'
+                             'from unseen jid: %s', msg['from'])
+            return
         args = body[1:].split()
         cmd = args.pop(0)
         if cmd not in self.commands: