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 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 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 import_doots(self): self.doots = BaseCommands.read_json("../data/doots.json")
def import_tells(self): self.tells = BaseCommands.read_json("../data/tells.json")
def import_places(self): self.places = BaseCommands.read_json("../data/places.json")
def import_grabs(self): self.grabs = BaseCommands.read_json("../data/grabs.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 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 bang(self, target): bangs = BaseCommands.read_json("/home/sean/golem/data/bangs.json") bang = random.choice(bangs) return target + bang
def import_places(self): self.places = BaseCommands.read_json( "/home/sean/golem/data/places.json")
def import_grabs(self): self.grabs = BaseCommands.read_json("/home/sean/golem/data/grabs.json")
def import_doots(self): self.doots = BaseCommands.read_json("/home/sean/golem/data/doots.json") if self.doots == None: self.doots = {}
def import_tells(self): self.tells = BaseCommands.read_json("/home/sean/golem/data/tells.json") if self.tells == None: self.tells = {}