"""
__author__ = 'Kaliko'
-__email__ = 'kaliko@azylum.org'
+__email__ = 'kaliko@azylum.org'
__version__ = '0.1'
__url__ = 'http://git.kaliko.me/?p=sid.git'
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
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)
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'])})
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__)
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:])
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
# '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):
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)
"""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
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__)
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
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})