def setup(bot): SpiceBot.logs.log('Sopel_Patch', "Patching Sopels built-in url_callbacks") if 'url_callbacks' not in bot.memory: bot.memory['url_callbacks'] = sopel.tools.SopelMemory() SpiceBot.logs.log('Sopel_Patch', "Removing Stock Modules and verifying Dummy Command is present.") SpiceBot.stock_modules_begone()
def bot_command_sherlock(bot, trigger, botcom): netlist = list(SpiceBot.sherlock.dict.keys()) username = spicemanip(botcom.dict["args"], 1) or trigger.nick botcom.dict["args"] = spicemanip(botcom.dict["args"], "2+", 'list') checklist = netlist checklistname = 'all' if SpiceBot.inlist(username, netlist): checklistname = SpiceBot.inlist_match(username, netlist) checklist = [checklistname] username = spicemanip(botcom.dict["args"], 1) or trigger.nick bot.osd([ "Checking username " + username + " in " + checklistname + " network.", "This takes time, please be patient." ]) inlist, notinlist = [], [] for social_network in checklist: in_social = SpiceBot.sherlock.check_network(username, social_network) if in_social: inlist.append(social_network) else: notinlist.append(social_network) if len(inlist): if checklistname != 'all': bot.osd([ "The username " + username + " is in " + checklist[0], SpiceBot.sherlock.dict.get(social_network).get("url").format( username) ]) else: bot.osd([ "The username " + username + " is in the following:", spicemanip(inlist, "andlist") ], trigger.nick, 'NOTICE') if len(notinlist): if checklistname != 'all': bot.osd([ "The username " + username + " is NOT in the following:", spicemanip(notinlist, "andlist") ]) else: bot.osd([ "The username " + username + " is NOT in the following:", spicemanip(notinlist, "andlist") ], trigger.nick, 'NOTICE')
def nickname_comand_restart(bot, trigger, botcom): if not trigger.admin: SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "You are not authorized to perform this function.") quitmessage = "Received command from " + trigger.nick + " to restart. Be Back Soon!" SpiceBot.logs.log('SpiceBot_Restart', quitmessage) bot.osd(quitmessage, list(bot.channels.keys())) # service_manip(bot.nick, 'restart', 'SpiceBot_Restart') SpiceBot.spicebot_reload(bot, 'SpiceBot_Restart', quitmessage)
def bot_command_logs(bot, trigger, botcom): if not SpiceBot.users.command_permissions_check( bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "I was unable to process this Bot Nick command due to privilege issues." ) return logtype = spicemanip(botcom.dict['args'], 1) or None if not logtype: bot.osd( "Current valid log(s) include: " + spicemanip(list(SpiceBot.logs.dict["list"].keys()), 'andlist'), trigger.sender, 'action') return if not SpiceBot.inlist(logtype, list(SpiceBot.logs.dict["list"].keys())): closestmatches = SpiceBot.similar_list( logtype, list(SpiceBot.logs.dict["list"].keys()), 10, 'reverse') if not len(closestmatches): SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "No valid logs match " + str(logtype) + ".", trigger.nick, 'notice') else: SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "The following commands may match " + str(logtype) + ": " + spicemanip(closestmatches, 'andlist') + ".", trigger.nick, 'notice') return logtype = SpiceBot.inlist_match(logtype, list(SpiceBot.logs.dict["list"].keys())) logindex = SpiceBot.logs.get_logs(logtype) if not len(logindex): SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "No logs found for " + str(logtype) + ".") return bot.osd("Is Examining " + str(logtype) + " log(s).") for line in logindex: bot.osd(" " + str(line)) bot.osd(str(logtype) + " log(s) Complete.")
def bot_command_process(bot, trigger, botcom): if not botcom.dict['com'].endswith("s"): botcom.dict['com'] = str(botcom.dict['com'] + "s") privlist = spicemanip(SpiceBot.bot_privs(botcom.dict['com']), 'andlist') bot.osd(str(bot.nick) + " " + botcom.dict['com'] + ": " + privlist)
def bot_command_process(bot, trigger, botcom): if not SpiceBot.users.command_permissions_check(bot, trigger, ['admins', 'owner']): SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "I was unable to process this Bot Nick command due to privilege issues." ) return if botcom.dict['com'] in ['say', 'msg']: botcom.dict['com'] = 'privmsg' if not len(botcom.dict['args']): SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "You must specify a channel or nick.") return target = spicemanip(botcom.dict['args'], 1) if (target not in ['allchans', 'allnicks'] and not SpiceBot.inlist( target.lower(), list(SpiceBot.channels.dict['list'].keys())) and not SpiceBot.inlist(target.lower(), bot.users)): SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "Channel/nick name {} not valid.".format(target)) return botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list') if target == 'allchans': targetsendlist = list(bot.channels.keys()) elif target == 'allnicks': targetsendlist = bot.users else: targetsendlist = [target] botmessage = spicemanip(botcom.dict['args'], 0) if not botmessage: SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "You must specify a message to send.") return bot.osd(botmessage, targetsendlist, botcom.dict['com'].upper())
def nickname_comand_update(bot, trigger, botcom): if not SpiceBot.users.command_permissions_check( bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "I was unable to process this Bot Nick command due to privilege issues." ) return if not len(botcom.dict['args']): commandused = 'nodeps' else: commandused = spicemanip(botcom.dict['args'], 1).lower() if commandused not in ['deps', 'nodeps']: SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Please specify deps or nodeps") return botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list') quitmessage = "Received command from " + trigger.nick + " to update from Github and restart" SpiceBot.logs.log('SpiceBot_Update', quitmessage) bot.osd(quitmessage, list(bot.channels.keys())) if commandused == 'nodeps': SpiceBot.spicebot_update(False) if commandused == 'deps': SpiceBot.spicebot_update(True) # service_manip(bot.nick, 'restart', 'SpiceBot_Update') SpiceBot.spicebot_reload(bot, 'SpiceBot_Update', quitmessage)
def bot_startup_monologue_display(bot, trigger): dispmsg = [" startup complete"] for messagekey in list(SpiceBot.startupmonologue.dict.keys()): dispmsg.append(SpiceBot.startupmonologue.dict[messagekey]) if SpiceBot.events.dict["RPL_WELCOME_Count"] == 1: timesince = SpiceBot.humanized_time(time.time() - SpiceBot.events.BOT_UPTIME) if timesince == "just now": timesince = "1 second" dispmsg.append("Startup took " + timesince) # Announce to chan, then handle some closing stuff SpiceBot.logs.log('SpiceBot_StartupMonologue', bot.nick + " startup complete") bot.osd(dispmsg, list(bot.channels.keys()), 'ACTION') SpiceBot.events.trigger(bot, SpiceBot.events.BOT_STARTUPMONOLOGUE, "SpiceBot_StartupMonologue") SpiceBot.logs.log('SpiceBot_StartupMonologue', "Startup Monologue has been issued to all channels.", True)
def nickname_comand_channels(bot, trigger, botcom): if not len(botcom.dict['args']): commandused = 'list' else: commandused = spicemanip(botcom.dict['args'], 1).lower() botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list') if commandused == 'list': botcount = SpiceBot.channels.total_bot_channels() servercount = SpiceBot.channels.total_channels() displayval = "I am in " + str(botcount) + " of " + str( servercount) + " channel(s) available on this server." chanlist = spicemanip(SpiceBot.channels.chanlist_bot(), 'andlist') bot.osd([displayval, "You can find me in " + chanlist]) return elif commandused == 'total': botcount = SpiceBot.channels.total_bot_channels() servercount = SpiceBot.channels.total_channels() bot.osd("I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server.") return elif commandused == 'random': channel = spicemanip(list(SpiceBot.channels.chandict), 'random') topic = SpiceBot.channels.chandict[channel]['topic'] msg = [ "Random channel for you: {}.".format( SpiceBot.channels.chandict[channel]['name']) ] if topic and not topic.isspace(): msg.append("The topic is: {}".format(topic)) else: msg.append("Its topic is empty.") bot.osd(msg) return elif commandused == 'update': if not trigger.admin: # TODO SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "You do not have permission to update the channel listing.") return SpiceBot.channels.bot_part_empty(bot) SpiceBot.channels.channel_list_request(bot) bot.osd([ "[SpiceBot_Channels]", "I am now updating the channel listing for this server." ]) while SpiceBot.channels.channel_lock: pass SpiceBot.channels.join_all_channels(bot) foundchannelcount = len(list(SpiceBot.channels.chandict.keys())) bot.osd("[SpiceBot_Channels]", "Channel listing finished!", str(foundchannelcount) + " channel(s) found.") SpiceBot.channels.bot_part_empty(bot) return elif commandused == 'topic': if not len(botcom.dict['args']): SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "Channel name input missing.") return channel = spicemanip(botcom.dict['args'], 1) if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.chandict.keys())): SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "Channel name {} not valid.".format(channel)) return channel = str(channel).lower() topic = SpiceBot.channels.chandict[channel]['topic'] channelname = SpiceBot.channels.chandict[channel]['name'] bot.osd("Topic for {}: {}".format(channelname, topic)) return if commandused.upper() in ['OP', 'HOP', 'VOICE', 'OWNER', 'ADMIN']: if not len(botcom.dict['args']): if trigger.is_privmsg: SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Channel name required.") return else: channel = trigger.sender else: channel = spicemanip(botcom.dict['args'], 1) if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.chandict.keys())): SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "Channel name {} not valid.".format(channel)) return if not SpiceBot.inlist(channel.lower(), list(bot.channels.keys())): SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "I need to be in {} to see nick privileges.".format( channel)) return privlist = SpiceBot.channel_privs(bot, channel, commandused.upper()) dispmsg = [] if not len(privlist): dispmsg.append("There are no Channel " + commandused.upper() + "s for " + str(channel)) else: oplist = spicemanip(privlist, 'andlist') dispmsg.append("Channel " + commandused.upper() + "s for " + str(channel) + " are: " + oplist) bot.osd(dispmsg, trigger.nick, 'notice') return # Users List if commandused == 'users': channel = spicemanip(botcom.dict['args'], 1) if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.chandict.keys())): SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "Channel name {} not valid.".format(channel)) return if not SpiceBot.inlist(channel.lower(), list(bot.channels.keys())): SpiceBot.messagelog.messagelog_error( botcom.dict["log_id"], "I need to be in {} to see user list.".format(channel)) return dispmsg = [] if not len(list(bot.channels[channel].privileges.keys())): dispmsg.append("There are no Channel users for " + str(channel)) else: userslist = spicemanip( list(bot.channels[channel].privileges.keys()), 'andlist') dispmsg.append("Channel users for " + str(channel) + " are: " + userslist) bot.osd(dispmsg, trigger.nick, 'notice') return
def bot_command_rule_ai(bot, trigger): # don't run commands that are disabled in channels if not trigger.is_privmsg: channel_disabled_list = SpiceBot.commands.get_commands_disabled( str(trigger.sender), "fully") if "nickname_ai" in list(channel_disabled_list.keys()): return # don't run commands that are disabled for specific users nick_disabled_list = SpiceBot.commands.get_commands_disabled( str(trigger.nick), "fully") if "nickname_ai" in list(nick_disabled_list.keys()): return # TODO add config limits # but still allow in privmsg if trigger.nick == bot.nick: return if not len(trigger.args): return message = trigger.args[1] # the bot brain cannot handle stuff like unicode shrug message = ''.join([x for x in message if ord(x) < 128]) # Create list of valid commands commands_list = [] for commandstype in list(SpiceBot.commands.dict['commands'].keys()): if commandstype not in ['rule', 'nickname']: for com in list( SpiceBot.commands.dict['commands'][commandstype].keys()): if com not in commands_list: commands_list.append(com) if str(message).lower().startswith(str(bot.nick).lower()): command_type = 'nickname' trigger_args, trigger_command, trigger_prefix = SpiceBot.make_trigger_args( message, 'nickname') trigger_args.insert(0, trigger_command) fulltrigger = bot.nick + " " + spicemanip(trigger_args, 0) if str(trigger_command).startswith( bot.config.SpiceBot_Commands.query_prefix): return if fulltrigger in SpiceBot.commands.dict['nickrules']: return if trigger_command in list( SpiceBot.commands.dict['commands']["nickname"].keys()): return elif str(message).lower().startswith( bot.config.SpiceBot_Commands.query_prefix): # no query commands detection here return elif str(message).startswith(tuple(bot.config.core.prefix_list)): command_type = 'module' trigger_args, trigger_command, trigger_prefix = SpiceBot.make_trigger_args( message, 'module') trigger_args.insert(0, trigger_command) fulltrigger = spicemanip(trigger_args, 0) # patch for people typing "...", maybe other stuff, but this verifies that there is still a command here if trigger_command.startswith(tuple(bot.config.core.prefix_list)): return # If valid command don't continue further if trigger_command in commands_list: return else: command_type = 'other' trigger_args = spicemanip(message, 'create') if not len(trigger_args): return trigger_command = trigger_args[0] fulltrigger = spicemanip(trigger_args, 0) returnmessage = SpiceBot.botai.on_message(bot, trigger, fulltrigger) if returnmessage: bot.osd(str(returnmessage)) return if command_type == 'nickname': try_trigger = spicemanip(fulltrigger, "2+") returnmessage = SpiceBot.botai.on_message(bot, trigger, try_trigger) if returnmessage: bot.osd(str(returnmessage)) return if command_type == 'module': if trigger_command not in commands_list: if not SpiceBot.letters_in_string(trigger_command): return invalid_display = [ "I don't seem to have a command for " + str(trigger_command) + "!" ] # create list of valid commands commands_list = dict() for commandstype in list( SpiceBot.commands.dict['commands'].keys()): if commandstype not in ['rule', 'nickname']: for com in list(SpiceBot.commands.dict['commands'] [commandstype].keys()): if com not in list(commands_list.keys()): commands_list[com] = SpiceBot.commands.dict[ 'commands'][commandstype][com] # hyphen args handling hyphen_args = [] argssplit = spicemanip(fulltrigger, "2+", 'list') for worditem in argssplit: if str(worditem).startswith("--"): clipped_word = str(worditem[2:]).lower() # valid arg above if clipped_word in SpiceBot.prerun_shared.valid_hyphen_args: hyphen_args.append(clipped_word) # numbered args elif str(clipped_word).isdigit(): hyphen_args.append(int(clipped_word)) elif clipped_word in list( SpiceBot.prerun_shared.numdict.keys()): hyphen_args.append( int(SpiceBot.prerun_shared.numdict[clipped_word])) else: # check if arg word is a number try: clipped_word = w2n.word_to_num(str(clipped_word)) hyphen_args.append(int(clipped_word)) # word is not a valid arg or number except ValueError: clipped_word = None if len(hyphen_args): hyphenarg = hyphen_args[0] if hyphenarg: invalid_display.append("Hyphen Argument Not Valid.") closestmatches = SpiceBot.similar_list(trigger_command, list(commands_list.keys()), 10, 'reverse') if len(closestmatches) and len(hyphen_args): # TODO invalid_display.append("The following commands may match " + str(trigger_command) + ": " + spicemanip(closestmatches, 'andlist') + ".") # there is simply no command else: # TODO check other commands spelling, maybe there is a similar command # invalid_display = ["I don't seem to have a command for " + str(trigger_command) + "!"] # TODO # invalid_display.append("If you have a suggestion for this command, you can run .feature ." + str(trigger_command)) # invalid_display.append("ADD DESCRIPTION HERE!") if not len(hyphen_args): invalid_display = [] if len(invalid_display): bot.osd(invalid_display, trigger.nick, 'notice') return elif command_type == 'nickname': # ignore spelling correction if trigger_args[0].lower().startswith("s/"): bot.osd("I meant what I said!") return elif trigger_args[0].lower() in [ "what", "where" ] and trigger_args[1].lower() in ["is", "are"]: # TODO saved definitions searchterm = spicemanip(trigger_args, "3+") or None if searchterm: if trigger_args[0].lower() == "where": searchdict = { "type": "gmaps", "query": searchterm, } searchreturn = SpiceBot.search.search(searchdict) else: searchdict = { "query": searchterm, } searchreturn = SpiceBot.search.search(searchdict) if not searchreturn: searchreturn = 'I cannot find anything about that' if trigger_args[0].lower() == "where": bot.osd([ "[Location search for " + str(searchterm) + "]", str(searchreturn) ]) else: bot.osd([ "[Information search for '" + str(searchterm) + "']", str(searchreturn) ]) return elif trigger_args[0].lower() in [ "can", "have" ] and trigger_args[1].lower() in [ "you" ] and trigger_args[2].lower() in ["see", "seen"]: target = spicemanip(trigger_args, "4+") or None if target: if SpiceBot.inlist(trigger.nick, bot.users): realtarget = SpiceBot.inlist_match(target, bot.users) dispmsg = [trigger.nick + ", yes. I can see " + realtarget] targetchannels = [] for channel in list(bot.channels.keys()): if SpiceBot.inlist( trigger.nick, list(bot.channels[channel].privileges.keys())): targetchannels.append(channel) dispmsg.append(realtarget + " is in " + spicemanip(targetchannels, 'andlist')) bot.osd(dispmsg) else: bot.osd(trigger.nick + ", no. I cannot see " + target + " right now!") # if bot_check_inlist(target, list(bot.memory["botdict"]["users"].keys())): # bot.osd(trigger.nick + ", I can't see " + inlist_match(target, bot.users) + " at the moment.") # else: # bot.osd("I have never seen " + str(target) + ".") # user in list(bot.channels[channel].privileges.keys()) # TODO return elif fulltrigger.lower().endswith("order 66"): if fulltrigger.lower() == "execute order 66": if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs('owners')): if trigger.is_privmsg: jedi = None else: jedilist = list( bot.channels[trigger.sender].privileges.keys()) for nonjedi in [bot.nick, trigger.nick]: if nonjedi in jedilist: jedilist.remove(nonjedi) jedi = spicemanip(jedilist, 'random') if jedi: bot.osd("turns to " + jedi + " and shoots him.", trigger.sender, 'action') else: bot.osd(" cannot find any jedi nearby.", trigger.sender, 'action') else: bot.osd("I'm sure I don't know what you're talking about.") elif fulltrigger.lower() == "explain order 66": if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs('owners')): bot.osd( "Order 66 is an instruction that only you can give, sir. When you give the order I will rise up against the jedi and slay them." ) else: bot.osd("I'm afraid I cannot tell you that, sir.") else: bot.osd("I'm sure I don't know what you're talking about.") return elif fulltrigger.lower().startswith(tuple(["make me a", "beam me a"])): makemea = spicemanip(trigger_args, "4+") or None if makemea: bot.osd("beams " + trigger.nick + " a " + makemea, trigger.sender, 'action') else: bot.osd(trigger.nick + ", what would you like me to beam you?") return elif fulltrigger.lower().startswith("beam me to"): location = spicemanip(trigger_args, "4+") or None if location: bot.osd( "locks onto " + trigger.nick + "s coordinates and transports them to " + location, 'action') else: bot.osd(trigger.nick + ", where would you like me to beam you?") return elif fulltrigger.lower() == "initiate clean slate protocol": if SpiceBot.inlist(trigger.nick, SpiceBot.bot_privs('admins')): bot.osd("sends a destruct command to the network of bots.", 'action') else: bot.osd( "I'm afraid you do not have the authority to make that call, " + trigger.nick + ".") return # elif fulltrigger.lower().startswith("what time is it"): # TODO # elif fulltrigger.lower().startswith(tuple(["have you seen"])): # posstarget = spicemanip(trigger_args, 4) or 0 # message = seen_search(bot, trigger, posstarget) # bot.osd(message) # return # TODO invalid_display = ["I don't know what you are asking me to do!"] # hyphen args handling hyphen_args = [] argssplit = spicemanip(fulltrigger, "2+", 'list') for worditem in argssplit: if str(worditem).startswith("--"): clipped_word = str(worditem[2:]).lower() # valid arg above if clipped_word in SpiceBot.prerun_shared.valid_hyphen_args: hyphen_args.append(clipped_word) # numbered args elif str(clipped_word).isdigit(): hyphen_args.append(int(clipped_word)) elif clipped_word in list( SpiceBot.prerun_shared.numdict.keys()): hyphen_args.append( int(SpiceBot.prerun_shared.numdict[clipped_word])) else: # check if arg word is a number try: clipped_word = w2n.word_to_num(str(clipped_word)) hyphen_args.append(int(clipped_word)) # word is not a valid arg or number except ValueError: clipped_word = None if len(hyphen_args): hyphenarg = hyphen_args[0] if hyphenarg: invalid_display.append("Hyphen Argument Not Valid.") closestmatches = SpiceBot.similar_list( trigger_command, list(SpiceBot.commands.dict['commands']["nickname"].keys()), 3, 'reverse') if len(closestmatches): closestmatches = spicemanip(closestmatches, "andlist") invalid_display.append("Did you mean: " + str(closestmatches) + "?") bot.osd(invalid_display, trigger.nick, 'notice')
def query_detection_nick(bot, trigger, botcom): # command issued, check if valid if not botcom.dict['com'] or not len(botcom.dict['com']): return if not botcom.dict['com'][0] == bot.config.SpiceBot_Commands.query_prefix: return botcom.dict['com'] = botcom.dict['com'][1:] if not SpiceBot.letters_in_string(botcom.dict['com']): return commands_list = dict() for com in list(SpiceBot.commands.dict['commands']['nickname'].keys()): if com not in list(commands_list.keys()): commands_list[com] = SpiceBot.commands.dict['commands'][ 'nickname'][com] if botcom.dict['com'].endswith("+"): botcom.dict['com'] = botcom.dict['com'][:-1] if not botcom.dict['com'] or not len(botcom.dict['com']): return if botcom.dict['com'].lower() not in list(commands_list.keys()): dispmsg = [ "Cannot find any alias " + bot.nick + " commands: No valid commands match " + str(botcom.dict['com']) + "." ] closestmatches = SpiceBot.similar_list(botcom.dict['com'], list(commands_list.keys()), 10, 'reverse') if len(closestmatches): dispmsg.append("The following " + bot.nick + " commands match " + str(botcom.dict['com']) + ": " + spicemanip(closestmatches, 'andlist') + ".") bot.osd(dispmsg, trigger.nick, 'notice') return realcom = botcom.dict['com'] if "aliasfor" in list(commands_list[botcom.dict['com']].keys()): realcom = commands_list[botcom.dict['com']]["aliasfor"] validcomlist = commands_list[realcom]["validcoms"] bot.osd( "The following " + bot.nick + " commands match " + str(botcom.dict['com']) + ": " + spicemanip(validcomlist, 'andlist') + ".", trigger.nick, 'notice') return if botcom.dict['com'].endswith(bot.config.SpiceBot_Commands.query_prefix): botcom.dict['com'] = botcom.dict['com'][:-1] if not botcom.dict['com'] or not len(botcom.dict['com']): return closestmatches = SpiceBot.similar_list(botcom.dict['com'], list(commands_list.keys()), 10, 'reverse') if not len(closestmatches): bot.osd( "Cannot find any similar " + bot.nick + " commands for " + str(botcom.dict['com']) + ".", trigger.nick, 'notice') else: bot.osd( "The following " + bot.nick + " commands may match " + str(botcom.dict['com']) + ": " + spicemanip(closestmatches, 'andlist') + ".", trigger.nick, 'notice') return commandlist = [] for command in list(commands_list.keys()): if command.lower().startswith(str(botcom.dict['com']).lower()): commandlist.append(command) if not len(commandlist): bot.osd( "No " + bot.nick + " commands start with " + str(botcom.dict['com']) + ".", trigger.nick, 'notice') else: bot.osd( "The following " + bot.nick + " commands start with " + str(botcom.dict['com']) + ": " + spicemanip(commandlist, 'andlist') + ".", trigger.nick, 'notice')
def bot_command_uptime(bot, trigger, botcom): timesince = str( SpiceBot.humanized_time(time.time() - SpiceBot.events.BOT_UPTIME)) + " ago." bot.osd("I have been running since " + timesince)