irc3 Irc bot

IrcBot

class irc3.IrcBot(*ini, **config)[source]

An IRC bot

defaults = {'asynchronous': True, 'connection': <class 'irc3.IrcConnection'>, 'ctcp': {'time': '{now:%c}', 'userinfo': '{realname}', 'version': 'irc3 {version} - {url}'}, 'encoding': 'utf8', 'flood_burst': 4, 'flood_rate': 1, 'flood_rate_delay': 1, 'host': 'localhost', 'loop': None, 'max_lag': 60, 'max_length': 512, 'mode': 0, 'nick': 'irc3', 'passwords': {}, 'port': 6667, 'realname': 'Irc bot based on irc3 http://irc3.readthedocs.io', 'server_config': {'CHANMODES': 'eIbq,k,flj,CFLMPQScgimnprstz', 'CHANTYPES': '#', 'PREFIX': '(ov)@+', 'STATUSMSG': '+@'}, 'ssl': False, 'ssl_verify': False, 'testing': False, 'timeout': 320, 'url': 'https://irc3.readthedocs.io/', 'username': 'irc3'}
add_signal_handlers()

Register handlers for UNIX signals (SIGHUP/SIGINT)

attach_events(*events, **kwargs)

Attach one or more events to the bot instance

away(message=None)[source]

mark ourself as away

call_many(callback, args)

callback is run with each arg but run a call per second

ctcp(target, message, nowait=False)[source]

send a ctcp to target

ctcp_reply(target, message, nowait=False)[source]

send a ctcp reply to target

dcc

return the DCCManager

dcc_accept(mask, filepath, port, pos)[source]

accept a DCC RESUME for an axisting DCC SEND. filepath is the filename to sent. port is the port opened on the server. pos is the expected offset

dcc_chat(mask, host=None, port=None)[source]

Open a DCC CHAT whith mask. If host/port are specified then connect to a server. Else create a server

dcc_get(mask, host, port, filepath, filesize=None)[source]

DCC GET a file from mask. filepath must be an absolute path with an existing directory. filesize is the expected file size.

dcc_send(mask, filepath)[source]

DCC SEND a file to mask. filepath must be an absolute path to existing file

detach_events(*events)

Detach one or more events from the bot instance

classmethod from_config(cfg, **kwargs)

return an instance configured with the cfg dict

invite(target, channel)[source]

invite target to a channel

ip

return bot’s ip as an ip_address object

join(target)[source]

join a channel

kick(channel, target, reason=None)[source]

kick target from channel

mode(target, *data)[source]

set user or channel mode

nick

nickname get/set

notice(target, message, nowait=False)[source]

send a notice to target

part(target, reason=None)[source]

quit a channel

privmsg(target, message, nowait=False)[source]

send a privmsg to target

quit(reason=None)[source]

disconnect

reload(*modules)

Reload one or more plugins

run(forever=True)

start the bot

send(data)[source]

send data to the server

send_line(data, nowait=False)[source]

send a line to the server. replace CR by spaces

server_config

return server configuration (rfc rpl 005):

>>> bot = IrcBot()
>>> print(bot.server_config['STATUSMSG'])
+@

The real values are only available after the server sent them.

topic(channel, topic=None)[source]

change or request the topic of a channel

unaway()[source]

mask ourself as no longer away

IrcConnection

class irc3.IrcConnection[source]

asyncio protocol to handle an irc connection

connection_lost(exc)[source]

Called when the connection is lost or closed.

The argument is an exception object or None (the latter meaning a regular EOF is received or the connection was aborted or closed).

connection_made(transport)[source]

Called when a connection is made.

The argument is the transport representing the pipe connection. To receive data, wait for data_received() calls. When the connection is closed, connection_lost() is called.

data_received(data)[source]

Called when some data is received.

The argument is a bytes object.

decode(data)[source]

Decode data with bot’s encoding