Development documentation
The Bot
- class sid.sid.MUCBot(jid, password, room, nick, log_level=20)[source]
Bases:
ClientXMPP
- Parameters:
- help(message, args)[source]
Returns a help string listing available options.
Automatically assigned to the “help” command.
- muc_presences
Keep track of MUC presences: {‘nick’: presence}
- prefix = '!'
Class attribute to define bot’s command prefix
Defaults to “!”
- register_bot_plugin(plugin_cls)[source]
Registers plugin, takes a class, the method instanciates the plugin
- Parameters:
plugin_cls (sid.plugin.Plugin) – A
sid.plugin.Plugin
class
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
- Parameters:
bot (sid.sid.MUCBot) – bot the plugin is load from
- 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 onrcv
- Parameters:
rcv – The received message (slixmpp object)
msg (dict,str) – The message to reply, refer to
sid.plugin.Plugin.send
formsg
format
Available plugins
Generic plugins
- class sid.echo.Echo(bot)[source]
Bases:
Plugin
Drops a message to be sent when someone gets online.
- class sid.feeds.Feeds(bot)[source]
Bases:
Plugin
Note
Feeds plugin depends on external module: feedparser
- FEEDS = ['https://www.debian.org/security/dsa', 'https://www.debian.org/News/news', 'https://tracker.debian.org/pkg/prosody/rss', 'https://tracker.debian.org/pkg/ejabberd/rss', 'https://planet.debian.org/atom.xml']
Default feeds to monitor
- TEMPO = 60
Time between feeds check
- 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).
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
Note
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
- muc_message(msg)[source]
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”, “bugs.debian.org/629234” and “bugreport.cgi?bug=629234”
- re_pkg = re.compile('(?P<package>[0-9a-z.+-]+)$')
Package name regexp