def handle_settodo(bot, ievent): """ t-set <name> <txt> .. add a todo to another user's todo list""" try: who = ievent.args[0] what = ' '.join(ievent.args[1:]) except IndexError: ievent.missing('<nick> <what>') ;return if not what: ievent.missing('<nick> <what>') ; return userhost = getwho(bot, who) if not userhost: ievent.reply("can't find userhost for %s" % who) ; return whouser = getusers().getname(userhost) if not whouser: ievent.reply("can't find user for %s" % userhost) ; return name = getusers().getname(ievent.userhost) if not getusers().permitted(userhost, name, 'todo'): ievent.reply("%s doesn't permit todo sharing for %s " % (who, name)) ; return what = "%s: %s" % (ievent.nick, what) ttime = strtotime(what) nr = 0 if not ttime == None: ievent.reply('time detected ' + time.ctime(ttime)) what = striptime(what) karma = plugs.get("jsb.plugs.db.karma2") if karma: alarmnr = alarms.add(bot.name, who, ttime, what) else: alarmnr = None nr = todo.add(whouser, what, ttime, alarmnr) else: nr = todo.add(whouser, what, None) ievent.reply('todo item %s added' % nr)
def handle_todo(bot, ievent): """ todo [<item>] .. show todo's or set todo item .. a time/date can be given. """ if len(ievent.args) > 0: handle_todo2(bot, ievent) ; return name = getusers().getname(ievent.userhost) try: todoos = todo.get(name) except KeyError: ievent.reply('i dont have todo info for %s' % user.name) ; return saytodo(bot, ievent, todoos)
def handle_lists(bot, ievent): """ list <listname> [',' <item>] """ if not ievent.rest: ievent.missing("<listname> [',' <item>]") return username = getusers().getname(ievent.userhost) try: listname, item = ievent.rest.split(',', 1) except ValueError: l = getlist(username, ievent.rest) if not l: ievent.reply('no %s list available' % ievent.rest) return result = [] for i in l: result.append("%s) %s" % (i[0], i[3])) ievent.reply("results: ", result) return listname = listname.strip().lower() item = item.strip() if not listname or not item: ievent.missing("<listname> [',' <item>]") return ok = 0 try: ok = addtolist(username, listname, item) except Exception, ex: handle_exception() ievent.reply('ERROR: %s' % str(ex)) return
def handle_listsdel(bot, ievent): """ list-del <listname> ',' <listofnrs> .. remove items with indexnr from list """ if not ievent.rest: ievent.missing('<listofnrs>') return try: nrs = [] for i in ievent.rest.split(): nrs.append(int(i)) except ValueError: ievent.reply('%s is not an integer' % i) return username = getusers().getname(ievent.userhost) nrs.sort() failed = [] itemsdeleted = 0 try: for i in nrs: result = delfromlist(username, i) if not result: failed.append(str(i)) else: itemsdeleted += 1 except Exception, ex: handle_exception() ievent.reply('ERROR: %s' % str(ex)) return
def handle_todosettime(bot, ievent): """ todo-settime [<channel|name>] <itemnr> <timestring> .. set time \ on todo item """ ttime = strtotime(ievent.txt) if ttime == None: ievent.reply("can't detect time") return txt = striptime(ievent.txt) try: (who, itemnr) = txt.split() except ValueError: try: (itemnr, ) = txt.split() who = getusers().getname(ievent.userhost) except ValueError: ievent.missing('[<channe|namel>] <itemnr> <timestring>') return try: itemnr = int(itemnr) except ValueError: ievent.missing('[<channel|name>] <itemnr> <timestring>') return who = who.lower() if not todo.settime(who, itemnr, ttime): ievent.reply('no todo %s found for %s' % (itemnr, who)) return ievent.reply('time of todo %s set to %s' % (itemnr, time.ctime(ttime)))
def handle_getpriority(bot, ievent): """ todo-getprio <[channel|name]> <itemnr> .. get priority of todo item """ try: (who, itemnr) = ievent.args except ValueError: try: itemnr = ievent.args[0] who = getusers().getname(ievent.userhost) except IndexError: ievent.missing('[<channel|name>] <itemnr>') return try: itemnr = int(itemnr) except ValueError: ievent.missing('[<channel|name>] <itemnr>') return who = who.lower() todoitems = todo.get(who) if not todoitems: ievent.reply('no todoitems known for %s' % who) return try: prio = todoitems[itemnr].priority except (IndexError, KeyError): ievent.reply('no todo item %s known for %s' % (itemnr, who)) return ievent.reply('priority is %s' % prio)
def __init__(self, cfg=None, usersin=None, plugs=None, botname=None, nick=None, bottype=None, nocbs=None, *args, **kwargs): logging.debug("type is %s" % str(type(self))) if cfg: self.cfg = cfg ; botname = botname or self.cfg.name if not botname: botname = u"default-%s" % str(type(self)).split('.')[-1][:-2] if not botname: raise Exception("can't determine botname") self.fleetdir = u'fleet' + os.sep + stripname(botname) if not self.cfg: self.cfg = Config(self.fleetdir + os.sep + u'config') self.cfg.name = botname or self.cfg.name if not self.cfg.name: raise Exception("name is not set in %s config file" % self.fleetdir) logging.debug("name is %s" % self.cfg.name) LazyDict.__init__(self) logging.debug("created bot with config %s" % self.cfg.tojson(full=True)) self.ecounter = 0 self.ids = [] self.aliases = getaliases() self.reconnectcount = 0 self.plugs = coreplugs self.gatekeeper = GateKeeper(self.cfg.name) self.gatekeeper.allow(self.user or self.jid or self.cfg.server or self.cfg.name) self.starttime = time.time() self.type = bottype or "base" self.status = "init" self.networkname = self.cfg.networkname or self.cfg.name or "" from jsb.lib.datadir import getdatadir datadir = getdatadir() self.datadir = datadir + os.sep + self.fleetdir self.maincfg = getmainconfig() self.owner = self.cfg.owner if not self.owner: logging.debug(u"owner is not set in %s - using mainconfig" % self.cfg.cfile) self.owner = self.maincfg.owner self.users = usersin or getusers() logging.debug(u"owner is %s" % self.owner) self.users.make_owner(self.owner) self.outcache = outcache self.userhosts = LazyDict() self.nicks = LazyDict() self.connectok = threading.Event() self.reconnectcount = 0 self.cfg.nick = nick or self.cfg.nick or u'jsb' try: if not os.isdir(self.datadir): os.mkdir(self.datadir) except: pass self.setstate() self.outputlock = thread.allocate_lock() try: self.outqueue = Queue.PriorityQueue() self.eventqueue = Queue.PriorityQueue() except AttributeError: self.outqueue = Queue.Queue() self.eventqueue = Queue.Queue() self.laterqueue = Queue.Queue() self.encoding = self.cfg.encoding or "utf-8" self.cmndperms = getcmndperms() self.outputmorphs = outputmorphs self.inputmorphs = inputmorphs try: if nocbs: self.nocbs = nocbs.split(",") except ValueError: logging.error("cannot determine %s nocbs argument" % self.nocbs) self.lastiter = 0
def handle_ignore(bot, event): """ arguments: <nick>|<userhost>|<JID> - ignore a user. """ if not event.rest: event.missing("<nick>|<userhost>|<JID>") ; return nick = event.rest userhost = getwho(bot, nick) if not userhost: userhost = event.rest perms = getusers().getperms(userhost) if perms and "OPER" in perms: event.reply("can't ignore OPER") ; return if not userhost in bot.state['ignore']: bot.state['ignore'].append(userhost) event.reply("%s added to ignore list" % userhost)
def handle_listsshow(bot, ievent): """ show avaiable lists """ username = getusers().getname(ievent.userhost) l = getlists(username) if not l: ievent.reply('no lists available') ; return else: result = [] for i in l: if not i[2] in result: result.append(i[2]) if result: ievent.reply("lists: ", result)
def handle_close(self, bot, ievent): if len(ievent.args) < 3: ievent.missing('<bug id> <action> <message>') return try: status = self.close(ievent.args[0], getusers().getname(ievent.userhost), ' '.join(ievent.args[2:]), ievent.args[1]) ievent.reply('ok') except AssertionError, e: ievent.reply('error: %s' % e)
def handle_ignore(bot, event): """ arguments: <nick>|<userhost>|<JID> - ignore a user. """ if not event.rest: event.missing("<nick>|<userhost>|<JID>") ; return nick = event.rest userhost = getwho(bot, nick) if not userhost: userhost = event.rest perms = getusers().getperms(userhost) if perms and "OPER" in perms: event.reply("can't ignore OPER") ; return if not userhost in bot.ignore: bot.ignore.append(userhost) event.reply("%s added to ignore list" % userhost)
def handle_listsshow(bot, ievent): """ show avaiable lists """ username = getusers().getname(ievent.userhost) l = getlists(username) if not l: ievent.reply('no lists available') return else: result = [] for i in l: if not i[2] in result: result.append(i[2]) if result: ievent.reply("lists: ", result)
def handle_cfgset(bot, event): if len(event.args) != 3: event.missing("<configname> <variable> <value>") ; return name, var, value = event.args if not var in allowset: event.reply("setting %s is not allowed" % var) ; return if name == "main": if not getusers().allowed(event.userhost, "OPER"): event.reply("you need to have OPER permissions to edit the mainconfig.") ; return mcfg = getmainconfig() try: mcfg[var] = int(value) except ValueError: mcfg[var] = value mcfg.save() event.done() else: event.reply('we current only support editing the "main" config.') ; return
def handle_todo(bot, ievent): """ todo [<item>] .. show todo's or set todo item .. a time/date can be given. """ if len(ievent.args) > 0: handle_todo2(bot, ievent) return name = getusers().getname(ievent.userhost) try: todoos = todo.get(name) except KeyError: ievent.reply('i dont have todo info for %s' % user.name) return saytodo(bot, ievent, todoos)
def handle_cfgset(bot, event): if len(event.args) != 3: event.missing("<configname> <variable> <value>") ; return name, var, value = event.args if not var in allowset: event.reply("setting %s is not allowed" % var) ; return if name == "main": if not getusers().allowed(event.userhost, "OPER"): event.reply("you need to have OPER permissions to edit the mainconfig.") ; return mcfg = getmainconfig() logging.info("using %s" % mcfg.cfile) try: mcfg[var] = int(value) except ValueError: mcfg[var] = value mcfg.save() event.done() else: event.reply('we current only support editing the "main" config.') ; return
def handle_gettodo(bot, ievent): """ t-get <nick> .. get todo of another user """ try: who = ievent.args[0] except IndexError: ievent.missing('<nick>') ; return userhost = getwho(bot, who) if not userhost: ievent.reply("can't find userhost for %s" % who) ; return users = getusers() whouser = users.getname(userhost) if not whouser: ievent.reply("can't find user for %s" % userhost) ; return name = users.getname(ievent.userhost) if not users.permitted(userhost, name, 'todo'): ievent.reply("%s doesn't permit todo sharing for %s " % (who, name)) ; return todoos = todo.get(whouser) saytodo(bot, ievent, todoos)
def handle_tododone(bot, ievent): """ t-done <listofnrs> .. remove todo items """ if len(ievent.args) == 0: ievent.missing('<list of nrs>') ; return try: nrs = [] for i in ievent.args: nrs.append(int(i)) except ValueError: ievent.reply('%s is not an integer' % i) ; return name = getusers().getname(ievent.userhost) nrdone = 0 for i in nrs: nrdone += todo.delete(name, i) if nrdone == 1: ievent.reply('%s item deleted' % nrdone) elif nrdone == 0: ievent.reply('no items deleted') else: ievent.reply('%s items deleted' % nrdone)
def handle_setpriority(bot, ievent): """ t-setprio [<channel|name>] <itemnr> <prio> .. show priority on todo item """ try: (who, itemnr, prio) = ievent.args except ValueError: try: (itemnr, prio) = ievent.args who = getusers().getname(ievent.userhost) except ValueError: ievent.missing('[<channe|namel>] <itemnr> <priority>') ; return try: itemnr = int(itemnr) prio = int(prio) except ValueError: ievent.missing('[<channel|name>] <itemnr> <priority>') ; return who = who.lower() if not todo.setprio(who, itemnr, prio): ievent.reply('no todo %s found for %s' % (itemnr, who)) ; return ievent.reply('priority set')
def handle_settodo(bot, ievent): """ t-set <name> <txt> .. add a todo to another user's todo list""" try: who = ievent.args[0] what = ' '.join(ievent.args[1:]) except IndexError: ievent.missing('<nick> <what>') return if not what: ievent.missing('<nick> <what>') return userhost = getwho(bot, who) if not userhost: ievent.reply("can't find userhost for %s" % who) return whouser = getusers().getname(userhost) if not whouser: ievent.reply("can't find user for %s" % userhost) return name = getusers().getname(ievent.userhost) if not getusers().permitted(userhost, name, 'todo'): ievent.reply("%s doesn't permit todo sharing for %s " % (who, name)) return what = "%s: %s" % (ievent.nick, what) ttime = strtotime(what) nr = 0 if not ttime == None: ievent.reply('time detected ' + time.ctime(ttime)) what = striptime(what) karma = plugs.get("jsb.plugs.db.karma2") if karma: alarmnr = alarms.add(bot.name, who, ttime, what) else: alarmnr = None nr = todo.add(whouser, what, ttime, alarmnr) else: nr = todo.add(whouser, what, None) ievent.reply('todo item %s added' % nr)
def handle_listsmerge(bot, ievent): """ merge 2 list """ try: (fromlist, tolist) = ievent.args except ValueError: ievent.missing('<fromlist> <tolist>') ; return username = getusers().getname(ievent.userhost) res = getlist(username, fromlist) if not res: ievent.reply('no %s list available or empty' % fromlist) ; return l = [] for i in res: l.append(i[3]) result = 0 try: result = mergelist(username, tolist, l) except Exception, ex: handle_exception() ievent.reply('ERROR: %s' % str(ex)) return
def handle_todo2(bot, ievent): """ set todo item """ if not ievent.rest: ievent.missing("<what>") ; return else: what = ievent.rest name = getusers().getname(ievent.userhost) ttime = strtotime(what) nr = 0 if not ttime == None: ievent.reply('time detected ' + time.ctime(ttime)) what = striptime(what) alarms = plugs.get("jsb.plugs.common.alarm") if alarms : alarmnr = alarms.alarms.add(bot.name, ievent.nick, ttime, what) else: alarmnr = None nr = todo.add(name, what, ttime, alarmnr) else: nr = todo.add(name, what, None) ievent.reply('todo item %s added' % nr)
def handle_getpriority(bot, ievent): """ todo-getprio <[channel|name]> <itemnr> .. get priority of todo item """ try: (who, itemnr) = ievent.args except ValueError: try: itemnr = ievent.args[0] who = getusers().getname(ievent.userhost) except IndexError: ievent.missing('[<channel|name>] <itemnr>') ; return try: itemnr = int(itemnr) except ValueError: ievent.missing('[<channel|name>] <itemnr>') ; return who = who.lower() todoitems = todo.get(who) if not todoitems: ievent.reply('no todoitems known for %s' % who) ; return try: prio = todoitems[itemnr].priority except (IndexError, KeyError): ievent.reply('no todo item %s known for %s' % (itemnr, who)) ; return ievent.reply('priority is %s' % prio)
def handle_todosettime(bot, ievent): """ todo-settime [<channel|name>] <itemnr> <timestring> .. set time \ on todo item """ ttime = strtotime(ievent.txt) if ttime == None: ievent.reply("can't detect time") ; return txt = striptime(ievent.txt) try: (who, itemnr) = txt.split() except ValueError: try: (itemnr, ) = txt.split() who = getusers().getname(ievent.userhost) except ValueError: ievent.missing('[<channe|namel>] <itemnr> <timestring>') ; return try: itemnr = int(itemnr) except ValueError: ievent.missing('[<channel|name>] <itemnr> <timestring>') ; return who = who.lower() if not todo.settime(who, itemnr, ttime): ievent.reply('no todo %s found for %s' % (itemnr, who)) ; return ievent.reply('time of todo %s set to %s' % (itemnr, time.ctime(ttime)))
def handle_tomorrow(bot, ievent): """ t-tomorrow .. show time related todo items for tomorrow """ username = getusers().getname(ievent.userhost) if ievent.rest: what = ievent.rest ttime = strtotime(what) if ttime != None: if ttime < today() or ttime > today() + 24*60*60: ievent.reply("%s is not tomorrow" % time.ctime(ttime + 24*60*60)) return ttime += 24*60*60 ievent.reply('time detected ' + time.ctime(ttime)) what = striptime(what) else: ttime = today() + 42*60*60 todo.add(username, what, ttime) ievent.reply('todo added') return todoos = todo.withintime(username, today()+24*60*60, today()+2*24*60*60) saytodo(bot, ievent, todoos)
def handle_tododone(bot, ievent): """ t-done <listofnrs> .. remove todo items """ if len(ievent.args) == 0: ievent.missing('<list of nrs>') return try: nrs = [] for i in ievent.args: nrs.append(int(i)) except ValueError: ievent.reply('%s is not an integer' % i) return name = getusers().getname(ievent.userhost) nrdone = 0 for i in nrs: nrdone += todo.delete(name, i) if nrdone == 1: ievent.reply('%s item deleted' % nrdone) elif nrdone == 0: ievent.reply('no items deleted') else: ievent.reply('%s items deleted' % nrdone)
def handle_listsdel(bot, ievent): """ list-del <listname> ',' <listofnrs> .. remove items with indexnr from list """ if not ievent.rest: ievent.missing('<listofnrs>') ; return try: nrs = [] for i in ievent.rest.split(): nrs.append(int(i)) except ValueError: ievent.reply('%s is not an integer' % i) ; return username = getusers().getname(ievent.userhost) nrs.sort() failed = [] itemsdeleted = 0 try: for i in nrs: result = delfromlist(username, i) if not result: failed.append(str(i)) else: itemsdeleted += 1 except Exception, ex: handle_exception() ievent.reply('ERROR: %s' % str(ex)) return
def handle_lists(bot, ievent): """ list <listname> [',' <item>] """ if not ievent.rest: ievent.missing("<listname> [',' <item>]") ; return username = getusers().getname(ievent.userhost) try: listname, item = ievent.rest.split(',', 1) except ValueError: l = getlist(username, ievent.rest) if not l: ievent.reply('no %s list available' % ievent.rest) ; return result = [] for i in l: result.append("%s) %s" % (i[0], i[3])) ievent.reply("results: ", result) return listname = listname.strip().lower() item = item.strip() if not listname or not item: ievent.missing("<listname> [',' <item>]") ; return ok = 0 try: ok = addtolist(username, listname, item) except Exception, ex: handle_exception() ievent.reply('ERROR: %s' % str(ex)) return
def handle_todo2(bot, ievent): """ set todo item """ if not ievent.rest: ievent.missing("<what>") return else: what = ievent.rest name = getusers().getname(ievent.userhost) ttime = strtotime(what) nr = 0 if not ttime == None: ievent.reply('time detected ' + time.ctime(ttime)) what = striptime(what) alarms = plugs.get("jsb.plugs.common.alarm") if alarms: alarmnr = alarms.alarms.add(bot.name, ievent.nick, ttime, what) else: alarmnr = None nr = todo.add(name, what, ttime, alarmnr) else: nr = todo.add(name, what, None) ievent.reply('todo item %s added' % nr)
def handle_gettodo(bot, ievent): """ t-get <nick> .. get todo of another user """ try: who = ievent.args[0] except IndexError: ievent.missing('<nick>') return userhost = getwho(bot, who) if not userhost: ievent.reply("can't find userhost for %s" % who) return users = getusers() whouser = users.getname(userhost) if not whouser: ievent.reply("can't find user for %s" % userhost) return name = users.getname(ievent.userhost) if not users.permitted(userhost, name, 'todo'): ievent.reply("%s doesn't permit todo sharing for %s " % (who, name)) return todoos = todo.get(whouser) saytodo(bot, ievent, todoos)
def handle_setpriority(bot, ievent): """ t-setprio [<channel|name>] <itemnr> <prio> .. show priority on todo item """ try: (who, itemnr, prio) = ievent.args except ValueError: try: (itemnr, prio) = ievent.args who = getusers().getname(ievent.userhost) except ValueError: ievent.missing('[<channe|namel>] <itemnr> <priority>') return try: itemnr = int(itemnr) prio = int(prio) except ValueError: ievent.missing('[<channel|name>] <itemnr> <priority>') return who = who.lower() if not todo.setprio(who, itemnr, prio): ievent.reply('no todo %s found for %s' % (itemnr, who)) return ievent.reply('priority set')
def handle_listsmerge(bot, ievent): """ merge 2 list """ try: (fromlist, tolist) = ievent.args except ValueError: ievent.missing('<fromlist> <tolist>') return username = getusers().getname(ievent.userhost) res = getlist(username, fromlist) if not res: ievent.reply('no %s list available or empty' % fromlist) return l = [] for i in res: l.append(i[3]) result = 0 try: result = mergelist(username, tolist, l) except Exception, ex: handle_exception() ievent.reply('ERROR: %s' % str(ex)) return
def handle_tomorrow(bot, ievent): """ t-tomorrow .. show time related todo items for tomorrow """ username = getusers().getname(ievent.userhost) if ievent.rest: what = ievent.rest ttime = strtotime(what) if ttime != None: if ttime < today() or ttime > today() + 24 * 60 * 60: ievent.reply("%s is not tomorrow" % time.ctime(ttime + 24 * 60 * 60)) return ttime += 24 * 60 * 60 ievent.reply('time detected ' + time.ctime(ttime)) what = striptime(what) else: ttime = today() + 42 * 60 * 60 todo.add(username, what, ttime) ievent.reply('todo added') return todoos = todo.withintime(username, today() + 24 * 60 * 60, today() + 2 * 24 * 60 * 60) saytodo(bot, ievent, todoos)
def infocb(bot, ievent): """ implement a !infoitem callback """ if getusers().allowed(ievent.userhost, 'USER'): data = info.get(ievent.execstr) if data: ievent.reply('%s is: ' % ievent.execstr, data)
def handle_today(bot, ievent): """ t-today .. show time related todo items for today """ name = getusers().getname(ievent.userhost) todoos = todo.withintime(name, today(), today() + 24 * 60 * 60) saytodo(bot, ievent, todoos)
def handle_todoweek(bot, ievent): """ todo-week .. show time related todo items for this week """ name = getusers().getname(ievent.userhost) todoos = todo.withintime(name, today(), today() + 7 * 24 * 60 * 60) saytodo(bot, ievent, todoos)
def handle_todotime(bot, ievent): """ t-time .. show time related todoos """ name = getusers().getname(ievent.userhost) todoos = todo.timetodo(name) saytodo(bot, ievent, todoos)
def __init__(self, cfg=None, usersin=None, plugs=None, botname=None, nick=None, bottype=None, nocbs=None, *args, **kwargs): logging.debug("type is %s" % str(type(self))) if cfg: self.cfg = cfg botname = botname or self.cfg.name if not botname: botname = u"default-%s" % str(type(self)).split('.')[-1][:-2] if not botname: raise Exception("can't determine botname") self.fleetdir = u'fleet' + os.sep + stripname(botname) if not self.cfg: self.cfg = Config(self.fleetdir + os.sep + u'config') self.cfg.name = botname or self.cfg.name if not self.cfg.name: raise Exception("name is not set in %s config file" % self.fleetdir) logging.debug("name is %s" % self.cfg.name) LazyDict.__init__(self) logging.debug("created bot with config %s" % self.cfg.tojson(full=True)) self.ecounter = 0 self.ids = [] self.aliases = getaliases() self.reconnectcount = 0 self.plugs = coreplugs self.gatekeeper = GateKeeper(self.cfg.name) self.gatekeeper.allow(self.user or self.jid or self.cfg.server or self.cfg.name) self.starttime = time.time() self.type = bottype or "base" self.status = "init" self.networkname = self.cfg.networkname or self.cfg.name or "" from jsb.lib.datadir import getdatadir datadir = getdatadir() self.datadir = datadir + os.sep + self.fleetdir self.maincfg = getmainconfig() self.owner = self.cfg.owner if not self.owner: logging.debug(u"owner is not set in %s - using mainconfig" % self.cfg.cfile) self.owner = self.maincfg.owner self.users = usersin or getusers() logging.debug(u"owner is %s" % self.owner) self.users.make_owner(self.owner) self.outcache = outcache self.userhosts = LazyDict() self.nicks = LazyDict() self.connectok = threading.Event() self.reconnectcount = 0 self.cfg.nick = nick or self.cfg.nick or u'jsb' try: if not os.isdir(self.datadir): os.mkdir(self.datadir) except: pass self.setstate() self.outputlock = thread.allocate_lock() try: self.outqueue = Queue.PriorityQueue() self.eventqueue = Queue.PriorityQueue() except AttributeError: self.outqueue = Queue.Queue() self.eventqueue = Queue.Queue() self.laterqueue = Queue.Queue() self.encoding = self.cfg.encoding or "utf-8" self.cmndperms = getcmndperms() self.outputmorphs = outputmorphs self.inputmorphs = inputmorphs try: if nocbs: self.nocbs = nocbs.split(",") except ValueError: logging.error("cannot determine %s nocbs argument" % self.nocbs) self.lastiter = 0
import pickle ## check for pycrypto dependancy try: import Crypto.Cipher.Blowfish import Crypto.Cipher.AES except ImportError: raise RequireError("PyCrypto is required for FiSH. Please install this library if you want to use this plug") ## defines cfg = PersistConfig() cfg.define("enable", 0) users = getusers() ## KeyStore class class KeyStore(Persist): def __init__(self, keyname): Persist.__init__(self, getdatadir() + os.sep + 'keys' + os.sep + 'fish' + os.sep + stripname(keyname)) ## make sure we get loaded def dummycb(bot, event): pass callbacks.add("START", dummycb) ## plugin def init():
def handle_todoweek(bot, ievent): """ todo-week .. show time related todo items for this week """ name = getusers().getname(ievent.userhost) todoos = todo.withintime(name, today(), today()+7*24*60*60) saytodo(bot, ievent, todoos)
def handle_today(bot, ievent): """ t-today .. show time related todo items for today """ name = getusers().getname(ievent.userhost) todoos = todo.withintime(name, today(), today()+24*60*60) saytodo(bot, ievent, todoos)
def handle_cfg(bot, event): if len(event.args) != 1: event.missing("<configname>") ; return name = event.args[0] if name == "main": if not getusers().allowed(event.userhost, "OPER"): event.reply("you need to have OPER permissions to edit the mainconfig.") ; return event.reply(getmainconfig().fordisplay())
## check for pycrypto dependancy try: import Crypto.Cipher.Blowfish import Crypto.Cipher.AES except ImportError: raise RequireError( "PyCrypto is required for FiSH. Please install this library if you want to use this plug" ) ## defines cfg = PersistConfig() cfg.define("enable", 0) users = getusers() ## KeyStore class class KeyStore(Persist): def __init__(self, keyname): Persist.__init__( self, getdatadir() + os.sep + 'keys' + os.sep + 'fish' + os.sep + stripname(keyname)) ## make sure we get loaded