1. girc.Reactor — Managing IRC Connections

class girc.Reactor

This class is the way you create and manage IRC connections.


Start running the reactor. This should run forever.


Disconnect all servers with a message.

Parameters:message (str) – Quit message to use on each connection.

1.1. Registering events

You can register events with the reactor to have them automagically registered with every server you connect to.

Reactor.handler(direction, verb, priority=10)

Register this function as an event handler.

  • direction (str) – in, out, both, raw.
  • verb (str) – Event name.
  • priority (int) – Handler priority (lower priority executes first).


These handlers print out a pretty raw log:

reactor = girc.Reactor()

@reactor.handler('in', 'raw', priority=1)
def handle_raw_in(event):
    print(event['server'].name, ' ->', escape(event['data']))

@reactor.handler('out', 'raw', priority=1)
def handle_raw_out(event):
    print(event['server'].name, '<- ', escape(event['data']))
Reactor.register_event(direction, verb, child_fn, priority=10)

Register an event with all servers.

  • direction (str) – in, out, both, raw.
  • verb (str) – Event name.
  • child_fn (function) – Handler function.
  • priority (int) – Handler priority (lower priority executes first).

1.2. Making connections

These functions let you make connections to IRC servers.

Reactor.create_server(server_name, *args, **kwargs)

Create an IRC server connection slot.

The server will actually be connected to when girc.client.ServerConnection.connect() is called later.

Parameters:server_name (str) – Name of the server, to be used for functions and accessing the server later through the reactor.
Returns:server – A not-yet-connected server.
Return type:girc.client.ServerConnection