1. Alexandre Macabies
  2. pypeul

Wiki

Clone wiki

pypeul / Callbacks

Here is a list of the callbacks you can reimplement, with their prototypes.

Most callbacks include a umask argument, which represents the "nick!user@host" part of the server command (this is the person who issued the command).

A unique user object can be obtained with umask.user, this object tracks the channels the user is in, and the user modes he has been given on this channel.

There is also a set of on_self_xxx() callbacks, which are called only when usermask represents the bot, they have the same arguments as the on_server_xxx() ones except the umask argument which does not exist.

# specialized callbacks

def on_connected(self):
    "Called when the connection with the server has been etablished"

def on_disconnected(self):
    "Called when the connection with the server has been closed"

def on_ready(self):
    "Alias for on_server_welcome (that is, the 001 reply of the server)"

def on_message(self, umask, sender, message):
def on_notice(self, umask, sender, message):
    "Called when you receive either a private or channel message / notice"
    "The sender parameter represents either the nickname or the channel name"

def on_channel_notice(self, umask, channel, message):
def on_channel_message(self, umask, channel, message):
    "Like on_message / on_notice, but for channels only"

def on_private_notice(self, umask, message):
def on_private_message(self, umask, message):
    "Like on_message / on_notice, but for private messages only"

def on_action(self, umask, sender, message):
    "Called when someone makes an action (eg /me does something) in a channel or private message"
    "The sender parameter represents either the nickname or the channel name"

def on_ctcp_request(self, umask, name, value):
def on_ctcp_XXX_request(self, umask, value):
    "Called when a ctcp request has been received"
    "on_ctcp_XXX_request is a specialized version, eg on_ctcp_version_request"

def on_ctcp_reply(self, umask, name, value):
def on_ctcp_XXX_reply(self, umask, value):
    "Called when a ctcp reply has been received"
    "on_ctcp_XXX_reply is a specialized version, eg on_ctcp_version_reply"

def on_banlist_received(self, channel, banlist):
    "Called when the banlist of a channel, which has already been requested with retrieve_ban_list"
    "has been received"

# generic callbacks
# these callbacks are directly generated from the raw response line
# the most common prototypes are shown below
# please refer to the RFC 2812 for more specific ones

def on_server_nick(self, umask, new_nick):
    "Called when a user changes his nick (this includes the bot as well)"

def on_server_quit(self, umask, message):
    "Called when a user quits the server, only if he has common channels with the bot"

def on_server_join(self, umask, channel):
    "Called when a user joins a channel"

def on_server_part(self, umask, channel, message=None):
    "Called when a user leaves a channel"

def on_server_kick(self, umask, channel, kicked_nick, reason=None):
    "Called when someone kicks another user"

def on_server_topic(self, umask, channel, new_topic):
    "Called when the topic of a channel is being changed by an user"

def on_server_mode(self, umask, target, *modestr):
    "Called when user or channel modes are being changed"
    "In order to get the original mode string, use ' '.join(modestr)"

def on_server_invite(self, umask, invited_nick, channel):
    "Called when someone invites someone else to a channel"

# numeric response codes are translated to text
# for instance, RPL_NAMREPLY is 353 and is called as on_server_namreply
# the full mapping of numeric replies can be found at the end of the pypeul.py file
# if a numeric reply is unkown, it will not be translated (on_server_NNN will be called)
# please refer to the RFC 2812 for their protoypes

Updated