Browse Source

Add support for fixed users in config.

Andres J. Diaz 5 years ago
parent
commit
bd9d59dbae
2 changed files with 6 additions and 2 deletions
  1. 3 1
      whistler/bot.py
  2. 3 1
      whistler/scripts.py

+ 3 - 1
whistler/bot.py

@@ -362,7 +362,9 @@ class WhistlerBot(object):
         functions.
 
         """
-        return jid not in self._rooms and jid in self.client.roster[self.user].keys()
+        return (jid not in self._rooms and
+                jid in self.client.roster[self.user].keys()) or \
+               (jid in self._initial_users)
 
     def register_user(self, jid, subscription="both"):
         """Register an user as valid user for the bot."""

+ 3 - 1
whistler/scripts.py

@@ -36,7 +36,8 @@ DEFAULT_CONFIG = {
     "port":      5222,
     "use_tls":   False,
     "ignore_ssl_cert": True,
-    "loglevel":  logging.WARNING
+    "loglevel":  logging.WARNING,
+    "users": set()
 }
 
 def get_no_defaults(config, section):
@@ -81,6 +82,7 @@ def main():
               resource = config.get("DEFAULT", "resource"),
               mention  = config.get("DEFAULT", "mention"),
               use_tls  = config.get("DEFAULT", "use_tls"),
+              users    = set(config.get("DEFAULT", "users").split(",")),
               server   = ( config.get("DEFAULT", "server"),
                            config.getint("DEFAULT", "port") ),
               rooms    = rooms,