Skip to content
This repository has been archived by the owner on Jan 30, 2024. It is now read-only.

Getting Started

Amber Yust edited this page Nov 12, 2013 · 35 revisions

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.

Overall Structure

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 IRC Client

The kitnirc.client.Client object represents a single IRC connection. To create a working connection, 3 steps are necessary:

  1. Instantiate a Client object, passing it the host (and optionally, port - default 6667) of the IRC server.
  2. Call the .connect() method of the Client object, passing it the nick you want to use.
  3. Eventually, call the .run() method of the Client 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.)

Getting Started

KitnIRC Features

References

Clone this wiki locally