]> kaliko git repositories - sid.git/blobdiff - sid/sid.py
Do not answer messages from unseen
[sid.git] / sid / sid.py
index 729f7b65784e5c9828c8782dc0ec8a9ac3bc741b..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:
@@ -148,7 +150,7 @@ class MUCBot(slixmpp.ClientXMPP):
         status = (pres['type'], pres['status'])
         self.__seen.update({nick: status})
 
-    def start(self, event):
+    async def start(self, event):
         """
         Process the session_start event.
 
@@ -159,7 +161,7 @@ class MUCBot(slixmpp.ClientXMPP):
         :param dict event: An empty dictionary. The session_start
                      event does not provide any additional data.
         """
-        self.get_roster()
+        await self.get_roster()
         self.send_presence()
         self.plugin['xep_0045'].join_muc(self.room,
                                          self.nick,