# -*- coding: utf-8 -*-
# Copyright (C) 1999-2002 Joel Rosdahl
-# Portions Copyright © 2011 Jason R. Coombs
+# Portions Copyright 2011 Jason R. Coombs
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
import types
import ssl as ssl_mod
import datetime
+import sys
try:
import pkg_resources
def __init__(self, fn_to_add_socket=None,
fn_to_remove_socket=None,
- fn_to_add_timeout=None):
+ fn_to_add_timeout=None,
+ debuglevel=0):
"""Constructor for IRC objects.
Optional arguments are fn_to_add_socket, fn_to_remove_socket
self.fn_to_remove_socket = None
self.fn_to_add_timeout = fn_to_add_timeout
+ self.debuglevel = debuglevel
self.connections = []
self.handlers = {}
self.delayed_commands = [] # list of DelayedCommands
self.add_global_handler("ping", _ping_ponger, -42)
+ self.debug(1, "IRC object created")
+
def server(self):
"""Creates and returns a ServerConnection object."""
if handler[1](connection, event) == "NO MORE":
return
+ def debug(self, level, errmsg):
+ """Display debugging information."""
+ #if self.debuglevel >= level:
+ sys.stderr.write("irclib[%d]: %s\n" % (self.debuglevel, errmsg))
+
def _remove_connection(self, connection):
"""[Internal]"""
self.connections.remove(connection)