irc Package

irc Package

connection Module

class earwigbot.irc.connection.IRCConnection(host, port, nick, ident, realname, logger)[source]

Interface with an IRC server.

action(target, msg, hidelog=False)[source]

Send a private message to a target on the server as an action.

host[source]

The hostname of the IRC server, like "irc.freenode.net".

ident[source]

Our ident on the server, like "earwig".

See http://en.wikipedia.org/wiki/Ident.

is_stopped()[source]

Return whether the IRC connection has been (or is to be) closed.

join(chan, hidelog=False)[source]

Join a channel on the server.

keep_alive()[source]

Ensure that we stay connected, stopping if the connection breaks.

loop()[source]

Main loop for the IRC connection.

mode(target, level, msg, hidelog=False)[source]

Send a mode message to the server.

nick[source]

Our nickname on the server, like "EarwigBot".

notice(target, msg, hidelog=False)[source]

Send a notice to a target on the server.

part(chan, msg=None, hidelog=False)[source]

Part from a channel on the server, optionally using an message.

ping(target, hidelog=False)[source]

Ping another entity on the server.

pong(target, hidelog=False)[source]

Pong another entity on the server.

port[source]

The port of the IRC server, like 6667.

realname[source]

Our realname (gecos field) on the server.

reply(data, msg, hidelog=False)[source]

Send a private message as a reply to a user on the server.

say(target, msg, hidelog=False)[source]

Send a private message to a target on the server.

stop(msg=None)[source]

Request the IRC connection to close at earliest convenience.

data Module

class earwigbot.irc.data.Data(my_nick, line, msgtype)[source]

Store data from an individual line received on IRC.

args[source]

List of all arguments given to this command.

For example, the message "!command arg1 arg2 arg3=val3" will produce the args ["arg1", "arg2", "arg3=val3"]. This is empty if the message was not a command or if it doesn’t have arguments.

chan[source]

Channel the message was sent from.

This will be equal to nick if the message is a private message.

command[source]

If the message is a command, this is the name of the command used.

See is_command for when a message is considered a command. If it’s not a command, this will be set to None.

host[source]

Hostname of the sender.

ident[source]

Ident of the sender.

is_command[source]

Boolean telling whether or not this message is a bot command.

A message is considered a command if and only if it begins with the character "!", ".", or the bot’s name followed by optional punctuation and a space (so EarwigBot: do something, EarwigBot, do something, and EarwigBot do something are all valid).

is_private[source]

True if this message was sent to us only, else False.

kwargs[source]

Dictionary of keyword arguments given to this command.

For example, the message "!command arg1=val1 arg2=val2" will produce the kwargs {"arg1": "val1", "arg2": "val2"}. This is empty if the message was not a command or if it doesn’t have keyword arguments.

line[source]

The full message received on IRC, including escape characters.

msg[source]

Text of the sent message, if it is a message, else None.

my_nick[source]

Our nickname, not the nickname of the sender.

nick[source]

Nickname of the sender.

reply_nick[source]

Nickname of the person to reply to. Sender by default.

serialize()[source]

Serialize this object into a tuple and return it.

trigger[source]

If this message is a command, this is what triggered it.

It can be either ”!” ("!help"), ”.” (".help"), or the bot’s name ("EarwigBot: help"). Otherwise, it will be None.

classmethod unserialize(data)[source]

Return a new Data object built from a serialized tuple.

frontend Module

class earwigbot.irc.frontend.Frontend(bot)[source]

Bases: earwigbot.irc.connection.IRCConnection

EarwigBot: IRC Frontend Component

The IRC frontend runs on a normal IRC server and expects users to interact with it and give it commands. Commands are stored as “command classes”, subclasses of Command. All command classes are automatically imported by commands.load() if they are in earwigbot.commands or the bot’s custom command directory (explained in the documentation).

rc Module

class earwigbot.irc.rc.RC(chan, msg)[source]

Store data from an event received from our IRC watcher.

parse()[source]

Parse a recent change event into some variables.

prettify()[source]

Make a nice, colorful message to send back to the IRC front-end.

pretty_edit = '\x02New {0}\x0f: \x0314[[\x0307{1}\x0314]]\x0306 * \x0303{2}\x0306 * \x0302{3}\x0306 * \x0310{4}'
pretty_log = '\x02New {0}\x0f: \x0303{1}\x0306 * \x0302{2}\x0306 * \x0310{3}'
re_color = <_sre.SRE_Pattern object at 0x1053e6d40>
re_edit = <_sre.SRE_Pattern object at 0x7f9a88698730>
re_log = <_sre.SRE_Pattern object at 0x105669030>

watcher Module

class earwigbot.irc.watcher.Watcher(bot)[source]

Bases: earwigbot.irc.connection.IRCConnection

EarwigBot: IRC Watcher Component

The IRC watcher runs on a wiki recent-changes server and listens for edits. Users cannot interact with this part of the bot. When an event occurs, we run it through some rules stored in our working directory under rules.py, which can result in wiki bot tasks being started or messages being sent to channels on the IRC frontend.

Table Of Contents

Previous topic

config Package

Next topic

tasks Package

This Page