def __init__(self, conf=None): # Load configuration self.conf = default_conf.copy() if conf: self.conf.update(conf) # Initialise socket sock = socket(AF_INET, SOCK_STREAM) address = gethostbyname(self.conf['server']) sock.connect((address, self.conf['port'])) Mac.__init__(self, sock)#, default=self.default) # Initialise events std.install(self) xirclib.install(self) self.link('433', self.err_nicknameinuse) self.link('001', self.registered) # Load plugins def plugins(): yield head for name in self.conf['plugins']: print '! plugin: %s' % name yield import_module(name) for plugin in plugins(): plugin.install(self) # Start registration self.nick = self.conf['nick'] self.send_cmd('NICK %s' % self.nick) self.send_cmd('USER %(user)s %(host)s %(server)s :%(name)s' % self.conf)
def __init__(self, conf=None): # Load configuration self.conf = default_conf.copy() if conf: self.conf.update(conf) # Initialise socket sock = socket(AF_INET, SOCK_STREAM) Mac.__init__(self, sock, is_read=True, is_write=True) if 'bind_addr' in self.conf: sock.bind(self.conf['bind_addr']) address = gethostbyname(self.conf['server']) sock.setblocking(0) sock.connect_ex((address, self.conf['port'])) # Initialise miscellaneous attributes self.isupport = { 'PREFIX': ('ohv','@%+'), 'CHANMODES': ('be','k','l','') } self.closing = False # Initialise flood-protection system self.send_times = [] self.flood_buffer = [] self.deferred_buffer = [] self.flood_active = False # Initialise events std.install(self) xirclib.install(self) self.link(ERR_NICKNAMEINUSE, self.h_err_nicknameinuse) self.link(RPL_WELCOME, self.h_rpl_welcome) self.link(RPL_ISUPPORT, self.h_rpl_isupport) self.link(TICK, self.h_tick) self.link('PRE_AUTOJOIN', self.h_pre_autojoin) # Load plugins self.conf['plugins'][:0] = ['plugins.standard.head'] self.load_plugins() # Start registration self.nick = self.conf['nick'] self.send_cmd('NICK %s' % self.nick) self.send_cmd('USER %(user)s %(host)s %(server)s :%(name)s' % self.conf)
def __init__(self, conf=None): # Load configuration self.conf = default_conf.copy() if conf: self.conf.update(conf) # Initialise socket sock = socket(AF_INET, SOCK_STREAM) Mac.__init__(self, sock, is_read=True, is_write=True) if "bind_addr" in self.conf: sock.bind(self.conf["bind_addr"]) address = gethostbyname(self.conf["server"]) sock.setblocking(0) sock.connect_ex((address, self.conf["port"])) # Initialise miscellaneous attributes self.isupport = {"PREFIX": ("ohv", "@%+"), "CHANMODES": ("be", "k", "l", "")} # Initialise flood-protection system self.send_times = [] self.flood_buffer = [] self.flood_active = False # Initialise events std.install(self) xirclib.install(self) self.link(ERR_NICKNAMEINUSE, self.h_err_nicknameinuse) self.link(RPL_WELCOME, self.h_rpl_welcome) self.link(RPL_ISUPPORT, self.h_rpl_isupport) self.link(TICK, self.h_tick) self.link("PRE_AUTOJOIN", self.h_pre_autojoin) # Load plugins self.conf["plugins"][:0] = ["plugins.standard.head"] self.load_plugins() # Start registration self.nick = self.conf["nick"] self.send_cmd("NICK %s" % self.nick) self.send_cmd("USER %(user)s %(host)s %(server)s :%(name)s" % self.conf)