supybot.ircmsgs

This module provides the basic IrcMsg object used throughout the bot to represent the actual messages. It also provides several helper functions to construct such messages in an easier way than the constructor for the IrcMsg object (which, as you’ll read later, is quite…full-featured :))

class supybot.ircmsgs.IrcMsg(s='', command='', args=(), prefix='', msg=None, reply_env=None)[source]

Bases: object

Class to represent an IRC message.

As usual, ignore attributes that begin with an underscore. They simply don’t exist. Instances of this class are not to be modified, since they are hashable. Public attributes of this class are .prefix, .command, .args, .nick, .user, and .host.

The constructor for this class is pretty intricate. It’s designed to take any of three major (sets of) arguments.

Called with no keyword arguments, it takes a single string that is a raw IRC message (such as one taken straight from the network).

Called with keyword arguments, it requires a command parameter. Args is optional, but with most commands will be necessary. Prefix is obviously optional, since clients aren’t allowed (well, technically, they are, but only in a completely useless way) to send prefixes to the server.

Since this class isn’t to be modified, the constructor also accepts a ‘msg’ keyword argument representing a message from which to take all the attributes not provided otherwise as keyword arguments. So, for instance, if a programmer wanted to take a PRIVMSG they’d gotten and simply redirect it to a different source, they could do this:

IrcMsg(prefix=’‘, args=(newSource, otherMsg.args[1]), msg=otherMsg)

tag(tag, value=True)[source]

Affect a key:value pair to this message.

tagged(tag)[source]

Get the value affected to a tag.

exception supybot.ircmsgs.MalformedIrcMsg[source]

Bases: exceptions.ValueError

supybot.ircmsgs.action(recipient, s, prefix='', msg=None)[source]

Returns a PRIVMSG ACTION to recipient with the message msg.

supybot.ircmsgs.ban(channel, hostmask, exception='', prefix='', msg=None)[source]

Returns a MODE to ban nick on channel.

supybot.ircmsgs.bans(channel, hostmasks, exceptions=(), prefix='', msg=None)[source]

Returns a MODE to ban each of nicks on channel.

supybot.ircmsgs.dehalfop(channel, nick, prefix='', msg=None)[source]

Returns a MODE to dehalfop nick on channel.

supybot.ircmsgs.dehalfops(channel, nicks, prefix='', msg=None)[source]

Returns a MODE to dehalfop each of nicks on channel.

supybot.ircmsgs.deop(channel, nick, prefix='', msg=None)[source]

Returns a MODE to deop nick on channel.

supybot.ircmsgs.deops(channel, nicks, prefix='', msg=None)[source]

Returns a MODE to deop each of nicks on channel.

supybot.ircmsgs.devoice(channel, nick, prefix='', msg=None)[source]

Returns a MODE to devoice nick on channel.

supybot.ircmsgs.devoices(channel, nicks, prefix='', msg=None)[source]

Returns a MODE to devoice each of nicks on channel.

supybot.ircmsgs.halfop(channel, nick, prefix='', msg=None)[source]

Returns a MODE to halfop nick on channel.

supybot.ircmsgs.halfops(channel, nicks, prefix='', msg=None)[source]

Returns a MODE to halfop each of nicks on channel.

supybot.ircmsgs.invite(nick, channel, prefix='', msg=None)[source]

Returns an INVITE for nick.

supybot.ircmsgs.isAction(msg)[source]

A predicate returning true if the PRIVMSG in question is an ACTION

supybot.ircmsgs.isCtcp(msg)[source]

Returns whether or not msg is a CTCP message.

supybot.ircmsgs.join(channel, key=None, prefix='', msg=None)[source]

Returns a JOIN to a channel

supybot.ircmsgs.joins(channels, keys=None, prefix='', msg=None)[source]

Returns a JOIN to each of channels.

supybot.ircmsgs.kick(channel, nick, s='', prefix='', msg=None)[source]

Returns a KICK to kick nick from channel with the message msg.

supybot.ircmsgs.kicks(channels, nicks, s='', prefix='', msg=None)[source]

Returns a KICK to kick each of nicks from channel with the message msg.

supybot.ircmsgs.modes(channel, args=(), prefix='', msg=None)[source]

Returns a MODE message for the channel for all the (mode, targetOrNone) 2-tuples in ‘args’.

supybot.ircmsgs.nick(nick, prefix='', msg=None)[source]

Returns a NICK with nick nick.

supybot.ircmsgs.notice(recipient, s, prefix='', msg=None)[source]

Returns a NOTICE to recipient with the message msg.

supybot.ircmsgs.op(channel, nick, prefix='', msg=None)[source]

Returns a MODE to op nick on channel.

supybot.ircmsgs.ops(channel, nicks, prefix='', msg=None)[source]

Returns a MODE to op each of nicks on channel.

supybot.ircmsgs.part(channel, s='', prefix='', msg=None)[source]

Returns a PART from channel with the message msg.

supybot.ircmsgs.parts(channels, s='', prefix='', msg=None)[source]

Returns a PART from each of channels with the message msg.

supybot.ircmsgs.password(password, prefix='', msg=None)[source]

Returns a PASS command for accessing a server.

supybot.ircmsgs.ping(payload, prefix='', msg=None)[source]

Takes a payload and returns the proper PING IrcMsg.

supybot.ircmsgs.pong(payload, prefix='', msg=None)[source]

Takes a payload and returns the proper PONG IrcMsg.

supybot.ircmsgs.prettyPrint(msg, addRecipients=False, timestampFormat=None, showNick=True)[source]

Provides a client-friendly string form for messages.

IIRC, I copied BitchX’s (or was it XChat’s?) format for messages.

supybot.ircmsgs.privmsg(recipient, s, prefix='', msg=None)[source]

Returns a PRIVMSG to recipient with the message msg.

supybot.ircmsgs.quit(s='', prefix='', msg=None)[source]

Returns a QUIT with the message msg.

supybot.ircmsgs.topic(channel, topic=None, prefix='', msg=None)[source]

Returns a TOPIC for channel with the topic topic.

supybot.ircmsgs.unAction(msg)[source]

Returns the payload (i.e., non-ACTION text) of an ACTION msg.

supybot.ircmsgs.unban(channel, hostmask, prefix='', msg=None)[source]

Returns a MODE to unban nick on channel.

supybot.ircmsgs.unbans(channel, hostmasks, prefix='', msg=None)[source]

Returns a MODE to unban each of nicks on channel.

supybot.ircmsgs.user(ident, user, prefix='', msg=None)[source]

Returns a USER with ident ident and user user.

supybot.ircmsgs.voice(channel, nick, prefix='', msg=None)[source]

Returns a MODE to voice nick on channel.

supybot.ircmsgs.voices(channel, nicks, prefix='', msg=None)[source]

Returns a MODE to voice each of nicks on channel.

supybot.ircmsgs.who(hostmaskOrChannel, prefix='', msg=None, args=())[source]

Returns a WHO for the hostmask or channel hostmaskOrChannel.

supybot.ircmsgs.whois(nick, mask='', prefix='', msg=None)

Returns a WHOIS for nick.

supybot.ircmsgs.whowas(nick, mask='', prefix='', msg=None)

Returns a WHOIS for nick.