def init(mods): store = Store() for fn in store.all("timer"): o = Event().load(fn) if "time" not in o: continue if time.time() < int(o.time): timer = Timer(int(o.time), o) launcher.launch(timer.start)
def init(mods): global seen store = Store() rss = store.last("results", "rss") if rss: seen = rss rss = Repeater(600, fetcher, name="rss.fetch") launcher.launch(rss.start)
def init(mods): store = Store() ncfg = store.last("cfg", "irc") if not ncfg: ncfg = cfg.irc ; ncfg.save() bot = IRC(ncfg) bot.connecting() launcher.launch(bot.push) launcher.launch(bot.loop) launcher.launch(bot.start)
def init(mods): store = Store() cfg = store.last("cfg", "xmpp") if not cfg: cfg = cfg.xmpp ; cfg.save() password = getpass.getpass() xmpp = XMPP(cfg.user, password) xmpp.update(cfg) launcher.launch(xmpp.core) launcher.launch(xmpp.loop) launcher.launch(xmpp.start)
def deleted(event): if not event.args: return store = Store() key = event.args[0] nr = 0 for fn in store.all(key): obj = Object().load(fn) if "deleted" not in obj: continue res = obj.get(key, "") if res: event.reply(res) nr += 1
def rm(event): try: key, match = event.rest.split(" ", 1) except ValueError: return nr = 0 store = Store() for fn in store.all(key): obj = Object().load(fn) if key not in obj: continue if match not in obj[key]: continue obj.deleted = True obj.sync() nr += 1 event.ok(nr)
def restore(event): try: key, match = event.args except ValueError: return nr = 0 store = Store() for fn in store.all(*event.args): obj = Object().load(fn) if key not in obj: continue if match not in obj[key]: continue if "deleted" not in obj: continue obj.deleted = False obj.sync() nr += 1 p.ok(nr)
def fetcher(event): result = [] thrs = [] store = Store() for fn in store.all("rss"): obj = Object().load(fn) if "deleted" in obj and obj.deleted: continue if "rss" not in obj: continue if "http" not in obj.rss: continue if cfg.rss.ignore and cfg.rss.ignore in obj.rss: continue fetch(obj) seen.sync() return result
def cfg(event): store = Store() if event._bot.type != "CLI": bcfg = store.last("cfg", event._bot.type.lower()) if not bcfg or "owner" not in bcfg or event.userhost != bcfg.owner: event.reply("EOWNER %s" % event.userhost) ; return obj = maincfg if event.args: ctype = event.args[0] obj = store.last("cfg", ctype) if not obj: obj = maincfg.get(ctype, None) try: key = event.args[1] value = event.args[2] if key in obj: if type(obj[key]) in [list, tuple]: obj[key].append(value) else: obj[key] = value obj.prefix = "cfg" obj.sync() except IndexError: pass if obj: event.show(obj)
def dump(event): if not event.args: return store = Store() objs = store.selected(event) for obj in objs: event.reply(obj.json())
def find(event): if not event.args: return nr = 1 store = Store() for obj in store.selected(event): event.display(obj, event.args, str(nr)) ; nr += 1
def last(event): store = Store() res = store.last(*event.args) if res: event.display(res, list(event.args))