-
Notifications
You must be signed in to change notification settings - Fork 7
Getting Started
Welcome! This page is designed for someone who has never used KitnIRC before and wants to get a sense of its general layout and features. It is designed to complement the example code provided within the repository.
KitnIRC has two major components:
- The
Client
, which handles the IRC protocol communications with the server (and can be used on its own if you just want a wrapper around IRC commands and messages). - The
Controller
, which provides a system for building independent modules that can interact with the IRC server.
The kitnirc.client.Client
object represents a single IRC connection. To create a working connection, 3 steps are necessary:
- Instantiate a
Client
object, passing it the host (and optionally, port - default 6667) of the IRC server. - Call the
.connect()
method of theClient
object, passing it the nick you want to use. - Eventually, call the
.run()
method of theClient
object, which will block and process communications to and from the IRC server.
A given Client
has a set of event handlers to which it will dispatch events based on communications with the IRC server - for instance, the WELCOME
event is dispatched once the client has joined the IRC server as a valid user. (A list of events can be found in client.py
- look for the definition of self.event_handlers
).
You can add a new handler for a given event by calling the add_handler
method on a Client
instance, passing it the name of the event and a function to call when that event is triggered. Event handler functions are called with the Client
instance that raised the event as their first argument, followed by zero or more additional arguments depending on which event they are handling. (To look up the exact arguments passed for a given event, see the COMMAND PARSERS
section of client.py
.)