]> kaliko git repositories - sid.git/commitdiff
Fixed tell "purge" command
authorkaliko <kaliko@azylum.org>
Sat, 24 Oct 2015 11:02:12 +0000 (13:02 +0200)
committerkaliko <kaliko@azylum.org>
Sat, 24 Oct 2015 11:02:12 +0000 (13:02 +0200)
Some code convention cleanup (pylint)

sid/__init__.py
sid/bts.py
sid/echo.py
sid/feeds.py
sid/ping.py
sid/sid.py

index 144c7bff6ed5e3ff8f6d70996cb8d6848e91af84..5f99c7c086d4df2e2dd5df360c928bc83fac8987 100644 (file)
@@ -3,6 +3,6 @@
 """
 
 __author__ = 'Kaliko'
-__email__  = 'kaliko@azylum.org'
+__email__ = 'kaliko@azylum.org'
 __version__ = '0.1'
 __url__ = 'http://git.kaliko.me/?p=sid.git'
index a19259ae660ee0f52510679ce97e1475348d734c..254a923cd4afa1658405fa0e984cc20bb99ee499 100644 (file)
@@ -24,13 +24,16 @@ from .plugin import Plugin, botcmd
 
 
 class Bugs(Plugin):
-    re_bugs = re_compile('(?<=#)(\d{6,7})')
+    """Gets bugs info from the BTS
+    """
+    re_bugs = re_compile(r'(?<=#)(\d{6,7})')
 
     def __init__(self, bot):
         Plugin.__init__(self, bot)
         bot.add_event_handler("muc::%s::message" % self.bot.room, self.muc_message)
 
     def muc_message(self, msg):
+        """Handler method dealing with MUC incoming messages"""
         # Does not reply to myself
         if msg['mucnick'] == self.bot.nick:
             return
index 94836d0b4c4766cb0ebc33015676ddcb66c7f188..534163c378c95df65e0ad888786c4c5481ccbf29 100644 (file)
@@ -18,6 +18,8 @@
 from .plugin import Plugin, botcmd
 
 class Echo(Plugin):
+    """Drop a message to be sent when someone gets online.
+    """
 
     def __init__(self, bot):
         Plugin.__init__(self, bot)
@@ -31,6 +33,7 @@ class Echo(Plugin):
         bot.add_event_handler("muc::%s::presence" %    self.bot.room, self.log_presence)
 
     def log_presence(self, pres):
+        """Register presence"""
         self.log.debug('%s: %s', pres['muc']['nick'], pres['type'])
         nick = pres['muc']['nick']
         self.presence.update({nick: (pres['muc']['role'], pres['type'])})
@@ -54,13 +57,13 @@ class Echo(Plugin):
         if len(args) == 1:
             if args[0] == 'queue':
                 msg = '\n'.join(['{0}:\n\t{1}'.format(k, '\n'.join(v))
-                                for k, v in self.inbox.items()])
+                                 for k, v in self.inbox.items()])
                 self.reply(message, msg)
                 return
             if args[0] == 'purge':
                 sender = message['from'].resource
                 if self.presence[sender][0] == 'moderator':
-                    self.online = set()
+                    self.inbox = dict()
                 return
         if len(args) < 2:
             msg = 'Please provide a message:\n{}'.format(self.tell.__doc__)
@@ -69,6 +72,7 @@ class Echo(Plugin):
         self._handle_msg(message)
 
     def _handle_msg(self, message):
+        """Format and drop message in the inbox"""
         sender = message['from'].resource
         recipient = message['body'].split()[1]
         tell_msg = ' '.join(message['body'].split()[2:])
@@ -78,9 +82,9 @@ class Echo(Plugin):
                 self.presence[recipient][1] == 'available'):
             return
         if recipient in self.inbox.keys():
-           self.inbox[recipient].append(letter)
+            self.inbox[recipient].append(letter)
         else:
-           self.inbox[recipient] = [letter]
+            self.inbox[recipient] = [letter]
 
 
 # VIM MODLINE
index a40f7662e8f14383d1d55089dd12f59fa91b82b5..5a33d6d5ccb40dbaa2c1f88d3c5a1795d02e16aa 100644 (file)
@@ -137,13 +137,13 @@ class Feeds(Plugin):
         # 'http://www.debian.org/News/news',
 
         # DPN in french
-       'http://www.debian.org/News/weekly/dwn.fr.rdf',
+        'http://www.debian.org/News/weekly/dwn.fr.rdf',
 
         # Misc
-       'http://rss.gmane.org/topics/excerpts/gmane.linux.debian.devel.announce',
-       'http://rss.gmane.org/gmane.linux.debian.user.security.announce',
-       'http://planet-fr.debian.net/users/rss20.xml',
-       'http://planet.debian.org/atom.xml',
+        'http://rss.gmane.org/topics/excerpts/gmane.linux.debian.devel.announce',
+        'http://rss.gmane.org/gmane.linux.debian.user.security.announce',
+        'http://planet-fr.debian.net/users/rss20.xml',
+        'http://planet.debian.org/atom.xml',
         ]
 
     def __init__(self, bot):
@@ -165,9 +165,7 @@ class Feeds(Plugin):
             return
         html = ['<a href="{0}">{1}</a>'.format(html_escape(u),
                                                html_escape(u[7:])
-                                               ) for u in Feeds.FEEDS]
-        msg = {
-                'mbody': 'Feeds:\n' + '\n'.join(Feeds.FEEDS),
-                'mhtml': 'Feeds:<br />' + '<br />'.join(html),
-                }
+                                              ) for u in Feeds.FEEDS]
+        msg = {'mbody': 'Feeds:\n' + '\n'.join(Feeds.FEEDS),
+               'mhtml': 'Feeds:<br />' + '<br />'.join(html),}
         self.reply(rcv, msg)
index 96d92c79ced2ef3c21f077477590e4a847759cdb..9fbab84a5cb19be9b5bcffbe81338fd2d86816f0 100644 (file)
@@ -27,10 +27,8 @@ class Ping(Plugin):
         """ping's answering a pong showing the bot is alive.
         !ping : You'll get back "pong"!
         """
-        msg = {
-                'mhtml':'!<a href="{0.PongURL}">pong</a>'.format(self),
-                'mbody':'!pong',
-                }
+        msg = {'mhtml':'!<a href="{0.PongURL}">pong</a>'.format(self),
+               'mbody':'!pong',}
         self.reply(rcv, msg)
 
 # VIM MODLINE
index 373209d2e6797c6040c27510b8e492d11745635e..604a63a6569d4432fcea52c8c3c3fa07c5482597 100644 (file)
@@ -46,7 +46,7 @@ class MUCBot(sleekxmpp.ClientXMPP):
     prefix = '!'
 
     def __init__(self, jid, password, room, nick, log_file=None,
-            log_level=logging.INFO):
+                 log_level=logging.INFO):
         super(MUCBot, self).__init__(jid, password)
 
         self.log = logging.getLogger(__package__)
@@ -90,6 +90,7 @@ class MUCBot(sleekxmpp.ClientXMPP):
         self.log.debug('set logger, log level : %s', log_level)
 
     def message(self, msg):
+        """Messages handler"""
         if msg['type'] not in ('groupchat', 'chat'):
             self.log.warning('Unhandled message')
             return
@@ -117,6 +118,7 @@ class MUCBot(sleekxmpp.ClientXMPP):
                 self.send_message(mto=msg['from'].bare, mbody=reply, mtype='groupchat')
 
     def _view(self, pres):
+        """Track known nick"""
         nick = pres['from']
         status = (pres['type'], pres['status'])
         self.__seen.update({nick: status})