Development documentation

The Bot

class sid.sid.MUCBot(jid, password, room, nick, log_level=20)[source]

Bases: ClientXMPP

  • jid (str) – jid to log with

  • password (str) – jid password

  • room (str) – conference room to join

  • nick (str) – Nickname to use in the room


disconnected handler

foreach_plugin(method, *args, **kwds)[source]
help(message, args)[source]

Returns a help string listing available options.

Automatically assigned to the “help” command.


Messages handler

Parses message received to detect prefix


Keep track of MUC presences: {‘nick’: presence}

prefix = '!'

Class attribute to define bot’s command prefix

Defaults to “!”


Registers plugin, takes a class, the method instanciates the plugin


plugin_cls (sid.plugin.Plugin) – A sid.plugin.Plugin class

async start(event)[source]

Process the session_start event.

Typical actions for the session_start event are requesting the roster and broadcasting an initial presence stanza.


event (dict) – An empty dictionary. The session_start event does not provide any additional data.

@sid.sid.botcmd(hidden, name)[source]

Decorator for bot command functions

  • hidden (bool) – is the command hidden in global help

  • name (str) – command name, default to decorated function name

Plugin base

The plugin class to derive from.

class sid.plugin.Plugin(bot)[source]

Simple Plugin object to derive from:

  • Exposes the bot object and its logger

  • Provides send helpers


bot (sid.sid.MUCBot) – bot the plugin is load from


Add handlers declared in self.hanlders

async ban(jid, reason)[source]

Coroutine to ban a jid from the room

  • jid (str) – JID to ban

  • reason (str) – Reason


list : List of tuples (event, handler)

log_level = None

Overriding bot log level for the plugin

reply(rcv, msg)[source]

Smart reply to message received.

Replies msg in private or on the muc depending on rcv


Remove handlers declared in self.hanlders

send(dest, msg, mtype='chat')[source]

Send msg to dest

  • dest (str) – Message recipient

  • msg (dict,str) – Message to send (use dict for xhtml-im)


if msg is a dict to provide xhmlt-im massages:

msg = {
    mbody: 'text',
    mhtml: '<b>text</b>,  # optional'

Empty method to override. Called on bot shutdown

Available plugins

Generic plugins

class sid.echo.Echo(bot)[source]

Bases: Plugin

Drops a message to be sent when someone gets online.


Handler method registering MUC participants presence

tell(message, args)[source]

Drops a message to be sent when someone gets online.

  • !tell queue : messages in queue

  • !tell <nick> <msg>: append <msg> to <nick> in queue

class sid.feeds.Feeds(bot)[source]

Bases: Plugin


Feeds plugin depends on external module: feedparser

FEEDS = ['', '', '', '', '']

Default feeds to monitor

TEMPO = 60

Time between feeds check

feeds(rcv, args)[source]

Monitors debian project related feeds.

  • !feeds : registred feeds list

  • !feeds last : last check time


Empty method to override. Called on bot shutdown

class sid.log.Log(bot)[source]

Bases: Plugin

Logs group chat participant presence.

The account running the bot need at least room moderation right to log participants JIDs (fallback to nickname).

dump(message, args)[source]

!dump : Dumps log as MUC message

write(message, args)[source]

Dump/save room presences log

!write : Writes log to file (use mktemp and return file location as MUC message)

class sid.rtbl.RTBL(bot)[source]

Bases: Plugin

Spam guard plugin for MUC.

async got_online(pres)[source]

Handler method for new MUC participants


Does bot have required permissions

node = 'muc_bans_sha256'

Pubsub server node to subscribe to

pubsub_server = ''

Pubsub server

async rtbl_ban(jid: JID)[source]

Ban jid in RTBL

rtbl_info(rcv, _)[source]

Show RTBL info

Debian plugins

Fetch packages info from the archive

>>> from sid.archive import Archive
class sid.archive.Archive(bot)[source]

Bases: Plugin

Fetches package info from the archive

archive(rcv, args)[source]

Fetches package info from the archive

!archive pkg-name : Returns package versions (by suite)

re_pkg = re.compile('(?P<package>[0-9a-z.+-]+)$')

Pakage name regexp

stable_codename = 'buster'

Current stable Suite

Intercepts bugs numbers in MUC messages and send info about it

>>> from sid.bts import Bugs
class sid.bts.Bugs(bot)[source]

Bases: Plugin

Gets bugs info from the BTS


This plugin depends on external module: python-debianbts

bugs(rcv, args)[source]

Gets bugs info from the BTS

!bugs pkg-name : Returns latest bug reports if any


Handler method dealing with MUC incoming messages.

Intercepts bugs number in MUC messages (as #629234), replies a bug summary.

re_bugs = re.compile('(?:(?<=#)|(?<=bugreport\\.cgi\\?bug=)|(?<=bugs\\.debian\\.org/))(\\d{6,7})')

Bug id regexp, intercepts bug id in strings : “#629234”, “” and “bugreport.cgi?bug=629234”

re_pkg = re.compile('(?P<package>[0-9a-z.+-]+)$')

Package name regexp