Documentation for Aioyoyo

Base Clients

class aioyoyo.client.IRCClient(loop=None, address=None, port=None, protocol=<class 'aioyoyo.protocol.ClientProtocol'>)[source]
close()[source]

Close the connection

connect()[source]

Initiate the connection, creates a connection using the defined protocol

connection_lost(exc)[source]

Called when the connection is dropped, by default prints the exception if there is one. Forwarded by protocol.connection_lost

connection_made()[source]

Called on a successful connection, by default forwarded by protocol.connection_made

data_received(data)[source]

Called when data is received by the connection, by default forwarded by protocol.data_received, passes bytes not str

run()[source]

Starts the client, blocking. For a non-blocking coroutine use client.connect()

send(*args)[source]

Send a message to the connected server. all arguments are joined with a space for convenience, for example the following are identical

>>> cli.send("JOIN %s" % some_room)
>>> cli.send("JOIN", some_room)

In python 3, all args must be of type str or bytes, BUT if they are str they will be converted to bytes with the encoding specified by the ‘encoding’ keyword argument (default ‘utf8’).

send_msg(message)[source]

Send a str to the server from absolute raw, none of the formatting from IRCClient.send

send_raw(data)[source]

Send raw bytes to the server, none of the formatting from IRCClient.send

class aioyoyo.client.CommandClient(cmd_handler, **kwargs)[source]

IRCClient, using a command handler

data_received(data)[source]

On IRCClient.data_received parse for a command and pass to the command_handler to run()

Command Handlers

class aioyoyo.cmdhandler.BotCommandHandler(client, command_handler)[source]

Complete command handler for bots

privmsg(prefix, dest, msg)[source]

Called when privmsg command is received, just awaits BotCommandHandler.tryBotCommand with the same args

tryBotCommand(prefix, dest, msg)[source]

Tests a command to see if its a command for the bot, returns True and calls self.processBotCommand(cmd, sender) if its is.

class aioyoyo.cmdhandler.CommandHandler(client)[source]

The most basic CommandHandler

get(in_command_parts)[source]

Finds a command commands may be dotted. each command part is checked that it does not start with and underscore and does not have an attribute “protected”. if either of these is true, ProtectedCommandError is raised. its possible to pass both “command.sub.func” and [“command”, “sub”, “func”].

run(command, *args)[source]

Finds and runs a command

class aioyoyo.cmdhandler.DefaultBotCommandHandler(client)[source]

Default command handler for bots. Methods/Attributes are made available as commands

getVisibleCommands(obj=None)[source]

Gets all visible commands, protected

help(sender, dest, arg=None)[source]

List all available commands or get help on a specific command

class aioyoyo.cmdhandler.DefaultCommandHandler(client)[source]

CommandHandler that provides methods for the normal operation of IRC. If you want your bot to properly respond to pings, etc, you should subclass this.

ping(prefix, server)[source]

Called on PING command, sends back PONG

aioyoyo.cmdhandler.protected(func)[source]

Decorator to protect functions from being called as commands

Default Protocol

class aioyoyo.protocol.ClientProtocol(client)[source]

Default protocol, forewards all events to the client

connection_lost(exc)[source]

Called on a lost connection, calls client.connection_lost

connection_made(transport)[source]

Called on a successful connection, calls client.connection_made

data_received(data)[source]

Called when data is received, calls client.data_received

send(message)[source]

Send an unencoded message to the server, will be encoded

send_raw(data)[source]

Send raw bytes to the server

Additional Helper Functions

class aioyoyo.helpers.HelperClient(loop=None, address=None, port=None, protocol=<class 'aioyoyo.protocol.ClientProtocol'>)[source]

Contains helper functions for common IRC commands, you may either inherit from HelperClient (which inherits IRCClient,) or you may just call the methods indirectly with HelperClient.method(client, *args), for example:

MyClient = IRCClient() HelperClient.msg(MyClient, ‘username’, ‘hi!’)

channel_list(cli)[source]

Send the LIST command

cs(cli, *args)[source]

Messages ChanServ with space joined *args

ctcp(cli, handle, cmd, msg='')[source]

Send CTCP command using PRIVMSG where handle is the user, cmd is the command and the optional msg

ctcp_reply(cli, handle, cmd, msg='')[source]

Forewards ctcp_reply command to notice function with added CTCP formatting

identify(cli, passwd, authuser='NickServ')[source]

Send IDENTIFY command with passwd, default authuser is NickServ

kick(cli, handle, channel, reason='')[source]

KICK handle from channel with optional reason

mode(cli, channel, mode, options=None)[source]

Send the MODE command to the given channel with optional options

msg(cli, user, msg)[source]

Send message msg to user with PRIVMSG command

msgrandom(cli, choices, dest, user=None)[source]

Function for random responses

names(cli, *channels)[source]

Send NAMES command, see source

ns(cli, *args)[source]

Messages NickServ with space joined *args

quit(cli, msg='gone')[source]

Send quit command with optional message, defaults to ‘gone’

user(cli, username, realname=None)[source]

Sends USER command with given username, uses realname instead if given

Defined Exceptions

exception aioyoyo.oyoyo.cmdhandler.CommandError(cmd)[source]
exception aioyoyo.oyoyo.cmdhandler.NoSuchCommandError(cmd)[source]
exception aioyoyo.oyoyo.cmdhandler.ProtectedCommandError(cmd)[source]
exception aioyoyo.oyoyo.cmdhandler.IRCClientError[source]

IRC Events

Num: Command Num: Command
001: welcome 349: endofexceptlist
002: yourhost 351: version
003: created 352: whoreply
004: myinfo 353: namreply
005: featurelist 361: killdone
010: toomanypeeps 362: closing
200: tracelink 363: closeend
201: traceconnecting 364: links
202: tracehandshake 365: endoflinks
203: traceunknown 366: endofnames
204: traceoperator 367: banlist
205: traceuser 368: endofbanlist
206: traceserver 369: endofwhowas
207: traceservice 371: info
208: tracenewtype 372: motd
209: traceclass 373: infostart
210: tracereconnect 374: endofinfo
211: statslinkinfo 375: motdstart
212: statscommands 376: endofmotd
213: statscline 377: motd2
214: statsnline 381: youreoper
215: statsiline 382: rehashing
216: statskline 384: myportis
217: statsqline 391: time
218: statsyline 392: usersstart
219: endofstats 393: users
221: umodeis 394: endofusers
231: serviceinfo 395: nousers
232: endofservices 401: nosuchnick
233: service 402: nosuchserver
234: servlist 403: nosuchchannel
235: servlistend 404: cannotsendtochan
241: statslline 405: toomanychannels
242: statsuptime 406: wasnosuchnick
243: statsoline 407: toomanytargets
244: statshline 409: noorigin
250: luserconns 411: norecipient
251: luserclient 412: notexttosend
252: luserop 413: notoplevel
253: luserunknown 414: wildtoplevel
254: luserchannels 421: unknowncommand
255: luserme 422: nomotd
256: adminme 423: noadmininfo
257: adminloc1 424: fileerror
258: adminloc2 431: nonicknamegiven
259: adminemail 432: erroneusnickname
261: tracelog 433: nicknameinuse
262: endoftrace 436: nickcollision
263: tryagain 437: unavailresource
265: n_local 441: usernotinchannel
266: n_global 442: notonchannel
300: none 443: useronchannel
301: away 444: nologin
302: userhost 445: summondisabled
303: ison 446: usersdisabled
305: unaway 451: notregistered
306: nowaway 461: needmoreparams
311: whoisuser 462: alreadyregistered
312: whoisserver 463: nopermforhost
313: whoisoperator 464: passwdmismatch
314: whowasuser 465: yourebannedcreep
315: endofwho 466: youwillbebanned
316: whoischanop 467: keyset
317: whoisidle 471: channelisfull
318: endofwhois 472: unknownmode
319: whoischannels 473: inviteonlychan
321: liststart 474: bannedfromchan
322: list 475: badchannelkey
323: listend 476: badchanmask
324: channelmodeis 477: nochanmodes
329: channelcreate 478: banlistfull
331: notopic 481: noprivileges
332: currenttopic 482: chanoprivsneeded
333: topicinfo 483: cantkillserver
341: inviting 484: restricted
342: summoning 485: uniqopprivsneeded
346: invitelist 491: nooperhost
347: endofinvitelist 492: noservicehost
348: exceptlist 501: umodeunknownflag
_ error _ dcc_connect
_ join _ dcc_disconnect
_ kick _ dccmsg
_ mode _ disconnect
_ part _ ctcp
_ ping _ ctcpreply

Indices and tables