webkit  2cdf99a9e3038c7e01b3c37e8ad903ecbe5eecf1
https://github.com/WebKit/webkit
Public Member Functions | Public Attributes | List of all members
webkitpy.thirdparty.irc.irclib.IRC Class Reference

Public Member Functions

def __init__ (self, fn_to_add_socket=None, fn_to_remove_socket=None, fn_to_add_timeout=None)
 
def server (self)
 
def process_data (self, sockets)
 
def process_timeout (self)
 
def process_once (self, timeout=0)
 
def process_forever (self, timeout=0.2)
 
def disconnect_all (self, message="")
 
def add_global_handler (self, event, handler, priority=0)
 
def remove_global_handler (self, event, handler)
 
def execute_at (self, at, function, arguments=())
 
def execute_delayed (self, delay, function, arguments=())
 
def dcc (self, dcctype="chat")
 

Public Attributes

 fn_to_add_socket
 
 fn_to_remove_socket
 
 fn_to_add_timeout
 
 connections
 
 handlers
 
 delayed_commands
 

Detailed Description

Class that handles one or several IRC server connections.

When an IRC object has been instantiated, it can be used to create
Connection objects that represent the IRC connections.  The
responsibility of the IRC object is to provide an event-driven
framework for the connections and to keep the connections alive.
It runs a select loop to poll each connection's TCP socket and
hands over the sockets with incoming data for processing by the
corresponding connection.

The methods of most interest for an IRC client writer are server,
add_global_handler, remove_global_handler, execute_at,
execute_delayed, process_once and process_forever.

Here is an example:

    irc = irclib.IRC()
    server = irc.server()
    server.connect(\"irc.some.where\", 6667, \"my_nickname\")
    server.privmsg(\"a_nickname\", \"Hi there!\")
    irc.process_forever()

This will connect to the IRC server irc.some.where on port 6667
using the nickname my_nickname and send the message \"Hi there!\"
to the nickname a_nickname.

Constructor & Destructor Documentation

◆ __init__()

def webkitpy.thirdparty.irc.irclib.IRC.__init__ (   self,
  fn_to_add_socket = None,
  fn_to_remove_socket = None,
  fn_to_add_timeout = None 
)
Constructor for IRC objects.

Optional arguments are fn_to_add_socket, fn_to_remove_socket
and fn_to_add_timeout.  The first two specify functions that
will be called with a socket object as argument when the IRC
object wants to be notified (or stop being notified) of data
coming on a new socket.  When new data arrives, the method
process_data should be called.  Similarly, fn_to_add_timeout
is called with a number of seconds (a floating point number)
as first argument when the IRC object wants to receive a
notification (by calling the process_timeout method).  So, if
e.g. the argument is 42.17, the object wants the
process_timeout method to be called after 42 seconds and 170
milliseconds.

The three arguments mainly exist to be able to use an external
main loop (for example Tkinter's or PyGTK's main app loop)
instead of calling the process_forever method.

An alternative is to just call ServerConnection.process_once()
once in a while.

Member Function Documentation

◆ add_global_handler()

def webkitpy.thirdparty.irc.irclib.IRC.add_global_handler (   self,
  event,
  handler,
  priority = 0 
)
Adds a global handler function for a specific event type.

Arguments:

    event -- Event type (a string).  Check the values of the
    numeric_events dictionary in irclib.py for possible event
    types.

    handler -- Callback function.

    priority -- A number (the lower number, the higher priority).

The handler function is called whenever the specified event is
triggered in any of the connections.  See documentation for
the Event class.

The handler functions are called in priority order (lowest
number is highest priority).  If a handler function returns
\"NO MORE\", no more handlers will be called.

◆ dcc()

def webkitpy.thirdparty.irc.irclib.IRC.dcc (   self,
  dcctype = "chat" 
)
Creates and returns a DCCConnection object.

Arguments:

    dcctype -- "chat" for DCC CHAT connections or "raw" for
       DCC SEND (or other DCC types). If "chat",
       incoming data will be split in newline-separated
       chunks. If "raw", incoming data is not touched.

◆ disconnect_all()

def webkitpy.thirdparty.irc.irclib.IRC.disconnect_all (   self,
  message = "" 
)
Disconnects all connections.

◆ execute_at()

def webkitpy.thirdparty.irc.irclib.IRC.execute_at (   self,
  at,
  function,
  arguments = () 
)
Execute a function at a specified time.

Arguments:

    at -- Execute at this time (standard \"time_t\" time).

    function -- Function to call.

    arguments -- Arguments to give the function.

◆ execute_delayed()

def webkitpy.thirdparty.irc.irclib.IRC.execute_delayed (   self,
  delay,
  function,
  arguments = () 
)
Execute a function after a specified time.

Arguments:

    delay -- How many seconds to wait.

    function -- Function to call.

    arguments -- Arguments to give the function.

◆ process_data()

def webkitpy.thirdparty.irc.irclib.IRC.process_data (   self,
  sockets 
)
Called when there is more data to read on connection sockets.

Arguments:

    sockets -- A list of socket objects.

See documentation for IRC.__init__.

◆ process_forever()

def webkitpy.thirdparty.irc.irclib.IRC.process_forever (   self,
  timeout = 0.2 
)
Run an infinite loop, processing data from connections.

This method repeatedly calls process_once.

Arguments:

    timeout -- Parameter to pass to process_once.

◆ process_once()

def webkitpy.thirdparty.irc.irclib.IRC.process_once (   self,
  timeout = 0 
)
Process data from connections once.

Arguments:

    timeout -- How long the select() call should wait if no
       data is available.

This method should be called periodically to check and process
incoming data, if there are any.  If that seems boring, look
at the process_forever method.

◆ process_timeout()

def webkitpy.thirdparty.irc.irclib.IRC.process_timeout (   self)
Called when a timeout notification is due.

See documentation for IRC.__init__.

◆ remove_global_handler()

def webkitpy.thirdparty.irc.irclib.IRC.remove_global_handler (   self,
  event,
  handler 
)
Removes a global handler function.

Arguments:

    event -- Event type (a string).

    handler -- Callback function.

Returns 1 on success, otherwise 0.

◆ server()

def webkitpy.thirdparty.irc.irclib.IRC.server (   self)
Creates and returns a ServerConnection object.

Member Data Documentation

◆ connections

webkitpy.thirdparty.irc.irclib.IRC.connections

◆ delayed_commands

webkitpy.thirdparty.irc.irclib.IRC.delayed_commands

◆ fn_to_add_socket

webkitpy.thirdparty.irc.irclib.IRC.fn_to_add_socket

◆ fn_to_add_timeout

webkitpy.thirdparty.irc.irclib.IRC.fn_to_add_timeout

◆ fn_to_remove_socket

webkitpy.thirdparty.irc.irclib.IRC.fn_to_remove_socket

◆ handlers

webkitpy.thirdparty.irc.irclib.IRC.handlers

The documentation for this class was generated from the following file: