def add_to_backlog(self, item): if self.backlog == None: self.backlog = [] self.backlog.append(item) BaseCommands.export_json("/home/sean/golem/data/backlog.json", self.backlog) return "Added to backlog"
def check_work_tells(self, sender): ret = "Work tells:" if sender not in self.work_tells.keys(): return "No Work tells for this user" for tell in self.work_tells[sender]: ret += "\n" + tell del self.work_tells[sender] BaseCommands.export_json("/home/sean/golem/data/wtells.json", self.work_tells) return ret
def work_tell(self, sender, args): target = args.split(' ', 1)[0] msg = args.split(' ', 1)[1] if self.work_tells == None: self.work_tells = {} if target not in self.work_tells.keys(): self.work_tells[target] = [] self.work_tells[target].append(sender + " said " + msg) BaseCommands.export_json("/home/sean/golem/data/wtells.json", self.work_tells) return "Work tell added"
def remind(self, sender, args): if args is not "": if sender not in self.reminds.keys(): self.reminds[sender] = "" self.reminds[sender] = self.reminds[sender] + " " + args BaseCommands.export_json("/home/sean/golem/data/reminds.json", self.reminds) return "Added remind" else: cur_reminds = self.reminds[sender] self.reminds[sender] = "" BaseCommands.export_json("/home/sean/golem/data/reminds.json", self.reminds) return cur_reminds
def get_help(self, command): if command == "": return "usage: help <command> - returns help for <command>. use the 'commands' command to get a list of commands" try: commands = BaseCommands.read_json( "/home/sean/golem/config/commands.json") return "usage: " + commands[command] except: return command + " is not currently supported\n" + self.fuzzy_command( command)
def __init__(self, g_token): self.import_tells() self.import_doots() self.import_grabs() self.import_places() self.doot_times = {} self.backlog = BaseCommands.read_json( "/home/sean/golem/data/backlog.json") self.work_tells = BaseCommands.read_json( "/home/sean/golem/data/wtells.json") self.banlist = BaseCommands.read_json( "/home/sean/golem/data/banlist.json") if self.banlist is None: self.banlist = [] self.reminds = BaseCommands.read_json( "/home/sean/golem/data/reminds.json") if self.reminds is None: self.reminds = {} self.gkey = g_token
def fuzzy_command(self, inp): commands = BaseCommands.read_json( "/home/sean/golem/config/commands.json") comms = commands.keys() best = 0 ret = "" for comm in comms: ratio = fuzz.ratio(inp, comm) if ratio > best: best = ratio ret = comm return "Closest Command:\n" + commands[ret]
def export_doots(self): BaseCommands.export_json("/home/sean/golem/data/doots.json", self.doots)
def import_tells(self): self.tells = BaseCommands.read_json("/home/sean/golem/data/tells.json") if self.tells == None: self.tells = {}
def export_doots(self): BaseCommands.export_json("../data/doots.json", self.doots)
def import_grabs(self): self.grabs = BaseCommands.read_json("/home/sean/golem/data/grabs.json")
def import_places(self): self.places = BaseCommands.read_json("../data/places.json")
def bang(self, target): bangs = BaseCommands.read_json("/home/sean/golem/data/bangs.json") bang = random.choice(bangs) return target + bang
def export_places(self): BaseCommands.export_json("/home/sean/golem/data/places.json", self.places)
def import_places(self): self.places = BaseCommands.read_json( "/home/sean/golem/data/places.json")
def export_grabs(self): BaseCommands.export_json("/home/sean/golem/data/grabs.json", self.grabs)
def import_grabs(self): self.grabs = BaseCommands.read_json("../data/grabs.json")
def export_tells(self): BaseCommands.export_json("../data/tells.json", self.tells)
def export_grabs(self): BaseCommands.export_json("../data/grabs.json", self.grabs)
def import_doots(self): self.doots = BaseCommands.read_json("/home/sean/golem/data/doots.json") if self.doots == None: self.doots = {}
def export_places(self): BaseCommands.export_json("../data/places.json", self.places)
def list_commands(self): commands = BaseCommands.read_json( "/home/sean/golem/config/commands.json") ret_com = [x + " usage: " + commands[x] for x in commands.keys()] return "\n".join(ret_com)
def import_tells(self): self.tells = BaseCommands.read_json("../data/tells.json")
def add_to_dl_queue(self, link): queue = BaseCommands.read_json("/home/sean/golem/data/queue.json") queue = [] if queue is None else queue queue.append(link) BaseCommands.export_json("/home/sean/golem/data/queue.json", queue) return "Added " + link + " to download queue"
def import_doots(self): self.doots = BaseCommands.read_json("../data/doots.json")
def export_tells(self): BaseCommands.export_json("/home/sean/golem/data/tells.json", self.tells)