Skip to content

Documentation Home

Avahe Kellenberger edited this page Nov 28, 2018 · 4 revisions

Documentation Home

Welcome to the prestige_irc documentation home page.

Use the table below to see the documentation pages for each module.

Modules
commands
connection
irc_connection
message

Examples

Creating a connection

Initialize a connection to an IRC network by creating a new IRCConnection, and invoking the connect function.

irc_connection = IRCConnection("YourBotsNick")
irc_connection.connect(ip_address="irc.freenode.net")

Listeners:

Add message listeners to the IRCConnection object.

def receive(msg):
    print(msg.text)

listener = MessageListener(message_filter=lambda msg: msg.command == Commands.PRIVMSG,
                           receive=receive)
irc_connection.add_listener(listener)

The above code will accept all PRIVMSG commands via the message_filter, then print the text of the IRCMessage. See prestige_irc.commands.Commands for the list of commands, and prestige_irc.message.IRCMessage for the message components.

Filters are invoked by MessageListener#accept, which is automatically called when an IRCConnection receives a message. This parameter can be excluded or set to None, which will cause MessageListener#accept to always return True. When this method returns true, MessageListener#receive is invoked.

See the code documentation for details.

Sending messages and IRC commands:

Most commands are supported by the API by default, and are placed in IRCConnection.

Commands are prefixed with cmd_, such as cmd_privmsg, cmd_join, and cmd_kick.

These preset commands will handle the message formatting that the IRC server requires, with documentation reflecting the RFC. Commands that are not yet supported by default can be sent manually with IRCConnection.send_command and/or IRCConnection.send.