supybot.irclib

Irc

It is usually the irc object given to plugin commands.

class supybot.irclib.Irc(network, callbacks=[])[source]

Bases: supybot.irclib.IrcCommandDispatcher, supybot.log.Firewalled

The base class for an IRC connection.

Handles PING commands already.

zombie

Whether or not this object represents a living IRC connection.

Type:bool
network

The name of the network this object is connected to.

Type:str
startedAt
Type:float
addCallback(callback)[source]

Adds a callback to the callbacks list.

Parameters:callback (supybot.irclib.IrcCallback) – A callback object
die(*args, **kwargs)

Makes the Irc object promise to die – but it won’t die (of its own volition) until all its queues are clear. Isn’t that cool?

dispatchCommand(command)

Given a string ‘command’, dispatches to doCommand.

do002(msg)[source]

Logs the ircd version.

doAuthenticateScramFirst(mechanism)[source]

Handle sending the client-first message of SCRAM auth.

doError(msg)[source]

Handles ERROR messages.

doNick(msg)[source]

Handles NICK messages.

doPing(msg)[source]

Handles PING messages.

doPong(msg)[source]

Handles PONG messages.

feedMsg(*args, **kwargs)

Called by the IrcDriver; feeds a message received.

getCallback(name)[source]

Gets a given callback by name.

isChannel(s)[source]

Helper function to check whether a given string is a channel on the network this Irc object is connected to.

monitor(targets)[source]

Increment a counter of how many callbacks monitor each target; and send a MONITOR + to the server if the target is not yet monitored.

queueMsg(msg)[source]

Queues a message to be sent to the server.

removeCallback(name)[source]

Removes a callback from the callback list.

reset()[source]

Resets the Irc object. Called when the driver reconnects.

sendMsg(msg)[source]

Queues a message to be sent to the server immediately

takeMsg(*args, **kwargs)

Called by the IrcDriver; takes a message to be sent.

unmonitor(targets)[source]

Decrements a counter of how many callbacks monitor each target; and send a MONITOR - to the server if the counter drops to 0.

IrcState

Used mainly as the state attribute of supybot.irclib.Irc objects.

class supybot.irclib.IrcState(history=None, supported=None, nicksToHostmasks=None, channels=None, capabilities_ack=None, capabilities_nak=None, capabilities_ls=None)[source]

Bases: supybot.irclib.IrcCommandDispatcher, supybot.log.Firewalled

Maintains state of the Irc connection. Should also become smarter.

addMsg(*args, **kwargs)

Updates the state based on the irc object and the message.

dispatchCommand(command)

Given a string ‘command’, dispatches to doCommand.

do004(irc, msg)[source]

Handles parsing the 004 reply

Supported user and channel modes are cached

getTopic(channel)[source]

Returns the topic for a given channel.

nickToHostmask(nick)[source]

Returns the hostmask for a given nick.

reset()[source]

Resets the state to normal, unconnected state.

ChannelState

Used mainly as the channels[‘#chan’] attribute of supybot.irclib.Irc objects.

class supybot.irclib.ChannelState[source]

Bases: supybot.utils.python.Object

addUser(user)[source]

Adds a given user to the ChannelState. Power prefixes are handled.

removeUser(user)[source]

Removes a given user from the channel.

replaceUser(oldNick, newNick)[source]

Changes the user oldNick to newNick; used for NICK changes.

Other classes

class supybot.irclib.Batch(type, arguments, messages)

Bases: tuple

arguments

Alias for field number 1

messages

Alias for field number 2

type

Alias for field number 0

class supybot.irclib.IrcCallback(*args, **kwargs)[source]

Bases: supybot.irclib.IrcCommandDispatcher, supybot.log.Firewalled

Base class for standard callbacks.

Callbacks derived from this class should have methods of the form “doCommand” – doPrivmsg, doNick, do433, etc. These will be called on matching messages.

callPrecedence(*args, **kwargs)

Returns a pair of (callbacks to call before me, callbacks to call after me)

die(*args, **kwargs)

Makes the callback die. Called when the parent Irc object dies.

inFilter(*args, **kwargs)

Used for filtering/modifying messages as they’re entering.

ircmsgs.IrcMsg objects are immutable, so this method is expected to return another ircmsgs.IrcMsg object. Obviously the same IrcMsg can be returned.

name(*args, **kwargs)

Returns the name of the callback.

outFilter(*args, **kwargs)

Used for filtering/modifying messages as they’re leaving.

As with inFilter, an IrcMsg is returned.

reset(*args, **kwargs)

Resets the callback. Called when reconnecting to the server.

class supybot.irclib.IrcCommandDispatcher[source]

Bases: object

Base class for classes that must dispatch on a command.

dispatchCommand(command)[source]

Given a string ‘command’, dispatches to doCommand.

class supybot.irclib.IrcMsgQueue(iterable=())[source]

Bases: object

Class for a queue of IrcMsgs. Eventually, it should be smart.

Probably smarter than it is now, though it’s gotten quite a bit smarter than it originally was. A method to “score” methods, and a heapq to maintain a priority queue of the messages would be the ideal way to do intelligent queuing.

As it stands, however, we simply keep track of ‘high priority’ messages, ‘low priority’ messages, and normal messages, and just make sure to return the ‘high priority’ ones before the normal ones before the ‘low priority’ ones.

dequeue()[source]

Dequeues a given message.

enqueue(msg)[source]

Enqueues a given message.

reset()[source]

Clears the queue.