def __init__(self, channel, nickname, server, port=6667, realname=None, password='', callsign='fidi'): if channel[0] != "#": # make sure channel starts with a # channel = "#" + channel self.nickname = self._nickname_wanted = nickname self.channel = channel self.realname = realname if realname else nickname self.password = password self.callsign = callsign self.identified = False self.alternatives = alternatives # load modules active_modules, active_alternatives = activate_modules() self.modules = [m(self) for m in active_modules] self.alternatives.merge_with(active_alternatives) # add alternatives from directory self.alternatives.merge_with(read_files()) self.alternatives.clean_duplicates() # build help index self.help_index = build_index(self.modules) super(FidiBot, self).__init__([(server, port)], nickname, realname) # set up rate limiting after 5 seconds to one message per second self.connection.execute_delayed(5, self.connection.set_rate_limit, (1,)) # set up keepalive self._pings_pending = 0 self._last_kicker = '' self.connection.execute_every(300, self._keepalive)
def __init__(self, channel, nickname, server, port=6667, realname=None, password=''): if channel[0] != "#": # make sure channel starts with a # channel = "#" + channel self.channel = channel self.realname = realname if realname else nickname self.password = password self.identified = False self.alternatives = alternatives # load modules active_modules, active_alternatives = activate_modules() self.modules = [m(self) for m in active_modules] self.alternatives.merge_with(active_alternatives) # add alternatives from directory self.alternatives.merge_with(read_files()) self.alternatives.clean_duplicates() super(FidiBot, self).__init__([(server, port)], nickname, realname)
private[cmd_name] = functions[fname] mod_index['private'] = private return mod_name, mod_index def build_index(modules): index = {'modules': {}} public = {} private = {} mods = index['modules'] for module in modules: mod_name, mod_index = build_module_index(module) mods[mod_name] = mod_index public.update(mod_index['public']) private.update(mod_index['private']) index.update({'public': public, 'private': private}) return index if __name__ == '__main__': from pprint import pprint as pp from modules import activate_modules modules, alts = activate_modules() index = build_index(modules) pp(index)