Skip to content
qll edited this page Sep 15, 2014 · 32 revisions

You can subscribe to various events in qllbot. Subscribe with the @lib.event.subscribe('event_name') decorator. Your function will recieve various parameters which are documented below.

Here is a list of all events ordered by name:

channel_message

Called when the bot recieves a message in a channel it joined to.

Parameters:
def on_channel_message(bot=None, msg=None):

  • 'bot': lib.bot.Bot instance
  • 'msg': lib.irc.Message instance

connected

Called when the bot has successfully connected to an IRC network. Beware, the bot might not have authenticated itself, yet.

Parameters:
def on_connected(bot=None):

  • 'bot': lib.bot.Bot instance

invite

Called when the bot gets invited into a channel.

Parameters:
def on_invite(bot=None, sender=None, channel=None):

  • 'bot': lib.bot.Bot instance
  • 'sender': lib.irc.User instance of the inviting user
  • 'channel': lib.irc.Channel instance of the channel the bot was invited in to

join

Called when a user joins a channel. Note that 'a user' could be the bot itself!

Parameters:
def on_join(bot=None, sender=None, channel=None):

  • 'bot': lib.bot.Bot instance
  • 'sender': lib.irc.User instance of the joining user
  • 'channel': lib.irc.Channel instance of the channel the user joined to

join_topic

Called when the bot is joining a channel in order to obtain the topic.

Parameters:
def on_join_topic(bot=None, channel=None, topic=''):

  • 'bot': lib.bot.Bot instance
  • 'channel': lib.irc.Channel instance
  • 'topic': str with the current channel topic

join_users

Called when the bot is joining a channel in order to obtain all the users in it.

Parameters:
def on_join_users(bot=None, channel=None, users=''):

  • 'bot': lib.bot.Bot instance
  • 'channel': lib.irc.Channel instance
  • 'users': string with all users separated by spaces (OPs have @ in front of their names)

kicked

Called when somebody got kicked from the channel.

Parameters:
def on_kicked(bot=None, msg=None, kicked=None):

  • 'bot': lib.bot.Bot instance
  • 'msg': lib.irc.Message instance (containing the user who kicked and the reason)
  • 'kicked': lib.irc.User instance of the user who got kicked

nick

Called when a user in a channel has changed his/her nickname.

Parameters:
def on_nick(bot=None, sender=None, old_nick='', new_nick=''):

  • 'bot': lib.bot.Bot instance
  • 'sender': lib.irc.User instance (already with the new nick)
  • 'old_nick': str with the old nickname
  • 'new_nick': str with the new nickname

part

Called when a user leaves the channel.

Parameters:
def on_part(bot=None, sender=None, channel=None):

  • 'bot': lib.bot.Bot instance
  • 'sender': lib.irc.User instance of the user who left the channel
  • 'channel': lib.irc.Channel instance

new_db

Called when the SQLite database is created. Can be used to install a database schema.

Parameters:
def on_new_db(db=None):

  • 'db': sqlite3.Connection instance

private_message

Called when the bot receives a private message.

Parameters:
def on_private_message(bot=None, priv_msg=None):

  • 'bot': lib.bot.Bot instance
  • 'priv_msg': lib.irc.Message instance

raw_message

Called when the bot receives any network communication from the IRC server. This is the raw IRC protocol!

Parameters:
def on_raw_message(bot=None, msg=''):

  • 'bot': lib.bot.Bot instance
  • 'msg': str with the IRC protocol message

topic

Called when the topic of the channel is changed.

Parameters:
def on_topic_change(bot=None, sender=None, channel=None, topic=''):

  • 'bot': lib.bot.Bot instance
  • 'sender': lib.irc.User instance of the user who set the topic
  • 'channel': lib.irc.Channel instance
  • 'old_topic': The old topic as a str
  • 'new_topic': The new topic as a str

watchdog_tick

Called every second. Can be used to delay sending of information or watchdog functionality.

Parameters:
def on_watchdog_tick(bot=None):

  • 'bot': lib.bot.Bot instance

Clone this wiki locally