test new spicemanip

This commit is contained in:
deathbybandaid 2019-07-06 07:56:43 -04:00
parent ca4f35aae5
commit b1501d94da
23 changed files with 158 additions and 505 deletions

View File

@ -15,7 +15,7 @@ from .Database import db as botdb
from .Config import config as botconfig
from .Read import read as botread
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
class SpiceBot_AI_MainSection(StaticSection):
@ -138,18 +138,18 @@ class SpiceBot_AI():
# bot items
for botitem in ["nick"]:
messagelist = spicemanip.main(message, "create")
messagelist = spicemanip(message, "create")
for i in range(len(messagelist)):
if messagelist[i].upper() == str(eval("bot." + botitem)).upper():
messagelist[i] = str("bot" + botitem).upper()
message = spicemanip.main(messagelist, 0)
message = spicemanip(messagelist, 0)
for triggeritem in ["nick", "sender"]:
messagelist = spicemanip.main(message, "create")
messagelist = spicemanip(message, "create")
for i in range(len(messagelist)):
if messagelist[i].upper() == str(eval("trigger." + botitem)).upper():
messagelist[i] = str("trigger" + botitem).upper()
message = spicemanip.main(messagelist, 0)
message = spicemanip(messagelist, 0)
return message

View File

@ -13,7 +13,7 @@ import os
import threading
import copy
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
import sopel_modules
from .Logs import logs
@ -196,7 +196,7 @@ class BotCommands():
maincom = command_dict["validcoms"][0]
if len(command_dict["validcoms"]) > 1:
comaliases = spicemanip.main(command_dict["validcoms"], '2+', 'list')
comaliases = spicemanip(command_dict["validcoms"], '2+', 'list')
else:
comaliases = []

View File

@ -8,7 +8,7 @@ from .Config import config as botconfig
from .Read import read as botread
from .Commands import commands as botcommands
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
from fake_useragent import UserAgent
import urllib
@ -134,13 +134,13 @@ class BotGif():
gifapiresults.extend(self.valid_api[currentapi]["cache"][searchdict["searchquery"].lower()])
if not len(gifapiresults):
return {"error": "No Results were found for '" + searchdict["query"] + "' in the " + str(spicemanip.main(searchdict['gifsearch'], 'orlist')) + " api(s)"}
return {"error": "No Results were found for '" + searchdict["query"] + "' in the " + str(spicemanip(searchdict['gifsearch'], 'orlist')) + " api(s)"}
random.shuffle(gifapiresults)
random.shuffle(gifapiresults)
randombad = True
while randombad:
gifdict = spicemanip.main(gifapiresults, "random")
gifdict = spicemanip(gifapiresults, "random")
try:
gifpage = requests.get(gifdict["returnurl"], headers=None)
@ -159,7 +159,7 @@ class BotGif():
gifapiresults = newlist
if not len(gifapiresults):
return {"error": "No Results were found for '" + searchdict["query"] + "' in the " + str(spicemanip.main(searchdict['gifsearch'], 'orlist')) + " api(s)"}
return {"error": "No Results were found for '" + searchdict["query"] + "' in the " + str(spicemanip(searchdict['gifsearch'], 'orlist')) + " api(s)"}
# return dict
gifdict['error'] = None

View File

@ -9,7 +9,7 @@ This Class stores logs in an easy to access manner
import threading
import os
import sys
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
from .Config import config as botconfig
@ -98,7 +98,7 @@ class BotLogs():
else:
if not line.startswith(tuple(stdio_ignore)) and not line.isspace():
debuglines.append(str(line))
loadedmodules = "Loaded: " + spicemanip.main(loadedmodules, 'andlist')
loadedmodules = "Loaded: " + spicemanip(loadedmodules, 'andlist')
debuglines.insert(1, loadedmodules)
return debuglines
@ -110,7 +110,7 @@ class BotLogs():
line = str(line).split(str(os.uname()[1] + " "))[-1]
lineparts = str(line).split(": ")
del lineparts[0]
line = spicemanip.main(lineparts, 0)
line = spicemanip(lineparts, 0)
if not line.isspace():
debuglines.append(str(line))
return debuglines

View File

@ -11,7 +11,7 @@ import copy
import datetime
from word2number import w2n
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
from .Tools import command_permissions_check, class_create
from .Commands import commands as botcommands
@ -41,7 +41,7 @@ def prerun(t_command_type='module', t_command_subtype=None):
botcom = class_create('botcom')
if t_command_type == "nickname":
check_nick = spicemanip.main(trigger.args[1], 1).lower()
check_nick = spicemanip(trigger.args[1], 1).lower()
if check_nick != str(bot.nick).lower():
return
else:
@ -129,7 +129,7 @@ def prerun_query(t_command_type='module', t_command_subtype=None):
botcom = class_create('botcom')
if t_command_type == "nickname":
check_nick = spicemanip.main(trigger.args[1], 1).lower()
check_nick = spicemanip(trigger.args[1], 1).lower()
if check_nick != str(bot.nick).lower():
return
else:
@ -207,22 +207,22 @@ def verify_channel(trigger):
def make_trigger_args(triggerargs_one, trigger_command_type='module'):
trigger_args = spicemanip.main(triggerargs_one, 'create')
trigger_args = spicemanip(triggerargs_one, 'create')
if trigger_command_type in ['nickname']:
trigger_prefix = spicemanip.main(trigger_args, 2).lower()[0]
trigger_prefix = spicemanip(trigger_args, 2).lower()[0]
if trigger_prefix.isupper() or trigger_prefix.islower():
trigger_prefix = None
trigger_command = spicemanip.main(trigger_args, 2).lower()
trigger_args = spicemanip.main(trigger_args, '3+', 'list')
trigger_command = spicemanip(trigger_args, 2).lower()
trigger_args = spicemanip(trigger_args, '3+', 'list')
else:
trigger_prefix = spicemanip.main(trigger_args, 1).lower()[0]
trigger_command = spicemanip.main(trigger_args, 1).lower()[1:]
trigger_args = spicemanip.main(trigger_args, '2+', 'list')
trigger_prefix = spicemanip(trigger_args, 1).lower()[0]
trigger_command = spicemanip(trigger_args, 1).lower()[1:]
trigger_args = spicemanip(trigger_args, '2+', 'list')
return trigger_args, trigger_command, trigger_prefix
def trigger_and_split(trigger_args):
trigger_args_list_split = spicemanip.main(trigger_args, "split_&&")
trigger_args_list_split = spicemanip(trigger_args, "split_&&")
if not len(trigger_args_list_split):
trigger_args_list_split.append([])
return trigger_args_list_split
@ -232,11 +232,11 @@ def trigger_argsdict_list(argsdict_default, and_split):
prerun_split = []
for trigger_args_part in and_split:
argsdict_part = copy.deepcopy(argsdict_default)
argsdict_part["args"] = spicemanip.main(trigger_args_part, 'create')
argsdict_part["args"] = spicemanip(trigger_args_part, 'create')
if len(argsdict_part["args"]) and (argsdict_part["args"][0] == "-a" or argsdict_part["args"][-1] == "-a"):
argsdict_part["adminswitch"] = True
if argsdict_part["args"][0] == "-a":
argsdict_part["args"] = spicemanip.main(argsdict_part["args"], '2+', 'list')
argsdict_part["args"] = spicemanip(argsdict_part["args"], '2+', 'list')
elif argsdict_part["args"][-1] == "-a":
del argsdict_part["args"][-1]
else:
@ -247,11 +247,11 @@ def trigger_argsdict_list(argsdict_default, and_split):
def trigger_argsdict_single(argsdict_default, trigger_args_part):
argsdict_part = copy.deepcopy(argsdict_default)
argsdict_part["args"] = spicemanip.main(trigger_args_part, 'create')
argsdict_part["args"] = spicemanip(trigger_args_part, 'create')
if len(argsdict_part["args"]) and (argsdict_part["args"][0] == "-a" or argsdict_part["args"][-1] == "-a"):
argsdict_part["adminswitch"] = True
if argsdict_part["args"][0] == "-a":
argsdict_part["args"] = spicemanip.main(argsdict_part["args"], '2+', 'list')
argsdict_part["args"] = spicemanip(argsdict_part["args"], '2+', 'list')
elif argsdict_part["args"][-1] == "-a":
del argsdict_part["args"][-1]
else:
@ -471,14 +471,14 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom):
"on", "off"
]:
target = spicemanip.main(botcom.dict["args"], 1) or trigger.nick
target = spicemanip(botcom.dict["args"], 1) or trigger.nick
if not target:
if botcom.dict["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]:
botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I enabling " + str(botcom.dict["comtext"]) + " usage for?")
else:
botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I disabling " + str(botcom.dict["comtext"]) + " usage for?")
return False
botcom.dict["args"] = spicemanip.main(botcom.dict["args"], "2+", "list")
botcom.dict["args"] = spicemanip(botcom.dict["args"], "2+", "list")
if not botdb.check_nick_id(target) and not botchannels.check_channel_bot(target, True):
botmessagelog.messagelog_error(botcom.dict["log_id"], "I don't know who/what " + str(target) + " is.")
@ -508,7 +508,7 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom):
botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " is already disabled for " + str(target))
return False
trailingmessage = spicemanip.main(botcom.dict["args"], 0) or "No reason given."
trailingmessage = spicemanip(botcom.dict["args"], 0) or "No reason given."
timestamp = str(datetime.datetime.utcnow())
botcommands.set_command_disabled(botcom.dict["realcomref"], target, timestamp, trailingmessage, trigger.nick)
@ -517,19 +517,19 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom):
if botcom.dict["hyphen_arg"] in ['multirun', 'multiruns']:
onoff = spicemanip.main(botcom.dict["args"], 1) or None
onoff = spicemanip(botcom.dict["args"], 1) or None
if not onoff or onoff not in ['enable', 'unblock', "activate", "on"]:
botmessagelog.messagelog_error(botcom.dict["log_id"], "Do you want to enable or disable " + str(botcom.dict["comtext"]) + " multirun usage?")
return False
target = spicemanip.main(botcom.dict["args"], 1) or trigger.nick
target = spicemanip(botcom.dict["args"], 1) or trigger.nick
if not target:
if onoff in ['enable', 'unblock', "activate", "on"]:
botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I enabling " + str(botcom.dict["comtext"]) + " multirun usage for?")
else:
botmessagelog.messagelog_error(botcom.dict["log_id"], "Who/Where am I disabling " + str(botcom.dict["comtext"]) + " multirun usage for?")
return False
botcom.dict["args"] = spicemanip.main(botcom.dict["args"], "2+", "list")
botcom.dict["args"] = spicemanip(botcom.dict["args"], "2+", "list")
if not botdb.check_nick_id(target) and not botchannels.check_channel_bot(target, True):
botmessagelog.messagelog_error(botcom.dict["log_id"], "I don't know who/what " + str(target) + " is.")
@ -559,7 +559,7 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom):
botmessagelog.messagelog_error(botcom.dict["log_id"], botcom.dict["comtext"] + " multirun is already disabled for " + str(target))
return False
trailingmessage = spicemanip.main(botcom.dict["args"], 0) or "No reason given."
trailingmessage = spicemanip(botcom.dict["args"], 0) or "No reason given."
timestamp = str(datetime.datetime.utcnow())
botcommands.set_command_disabled(botcom.dict["realcomref"], target, timestamp, trailingmessage, trigger.nick, "multirun")
@ -583,11 +583,11 @@ def trigger_hyphen_arg_handler(bot, trigger, botcom):
return False
elif botcom.dict["hyphen_arg"] in ['contribs', 'contrib', "contributors"]:
botmessagelog.messagelog(botcom.dict["log_id"], "The contributors of the " + str(botcom.dict["comtext"]) + " command are " + spicemanip.main(botcom.dict["dict"]["contributors"], "andlist") + ".")
botmessagelog.messagelog(botcom.dict["log_id"], "The contributors of the " + str(botcom.dict["comtext"]) + " command are " + spicemanip(botcom.dict["dict"]["contributors"], "andlist") + ".")
return False
elif botcom.dict["hyphen_arg"] in ['alias', 'aliases']:
botmessagelog.messagelog(botcom.dict["log_id"], "The alaises of the " + str(botcom.dict["comtext"]) + " command are " + spicemanip.main(botcom.dict["dict"]["validcoms"], "andlist") + ".")
botmessagelog.messagelog(botcom.dict["log_id"], "The alaises of the " + str(botcom.dict["comtext"]) + " command are " + spicemanip(botcom.dict["dict"]["validcoms"], "andlist") + ".")
return False
return False

View File

@ -7,7 +7,7 @@ This is the SpiceBot Reddit system.
from sopel.config.types import StaticSection, ValidatedAttribute
from sopel.formatting import bold, color, colors
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
import datetime as dt
import praw
@ -56,7 +56,7 @@ class BotReddit():
def user_handler(self, trigger_argsdict):
subcommand_valid = ['check']
subcommand = spicemanip.main([x for x in trigger_argsdict["args"] if x in subcommand_valid], 1) or 'check'
subcommand = spicemanip([x for x in trigger_argsdict["args"] if x in subcommand_valid], 1) or 'check'
userreal = self.reddit_user_exists(trigger_argsdict["command"])
if not userreal["exists"]:
@ -97,7 +97,7 @@ class BotReddit():
def subreddit_handler(self, trigger_argsdict):
subcommand_valid = ['check', 'hot', 'new', 'top', 'random', 'controversial', 'gilded', 'rising', 'best']
subcommand = spicemanip.main([x for x in trigger_argsdict["args"] if x in subcommand_valid], 1) or 'check'
subcommand = spicemanip([x for x in trigger_argsdict["args"] if x in subcommand_valid], 1) or 'check'
fullrurul = str("https://www.reddit.com/" + trigger_argsdict["slashcomm"] + "/" + trigger_argsdict["command"])
@ -116,9 +116,9 @@ class BotReddit():
return dispmsg
if subcommand == 'random':
targnum = spicemanip.main([x for x in trigger_argsdict["args"] if str(x).isdigit()], 1) or 500
targnum = spicemanip([x for x in trigger_argsdict["args"] if str(x).isdigit()], 1) or 500
else:
targnum = spicemanip.main([x for x in trigger_argsdict["args"] if str(x).isdigit()], 1) or 1
targnum = spicemanip([x for x in trigger_argsdict["args"] if str(x).isdigit()], 1) or 1
targnum = int(targnum)
if subcommand == 'new':
@ -162,11 +162,11 @@ class BotReddit():
return dispmsg
def trigger_handler(self, trigger):
trigger_args = spicemanip.main(trigger.args[1], 'create')
trigger_args = spicemanip(trigger.args[1], 'create')
trigger_argsdict = {
"slashcomm": spicemanip.main(trigger_args, 1).lower()[:1],
"command": spicemanip.main(trigger_args, 1).lower()[2:],
"args": spicemanip.main(trigger_args, "2+", 'list')
"slashcomm": spicemanip(trigger_args, 1).lower()[:1],
"command": spicemanip(trigger_args, 1).lower()[2:],
"args": spicemanip(trigger_args, "2+", 'list')
}
if trigger_argsdict["slashcomm"] == "u":
trigger_argsdict["urltypetxt"] = "user"

View File

@ -14,7 +14,7 @@ from operator import itemgetter
from collections import abc
from pygit2 import clone_repository
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
from .Logs import logs
from .Config import config as botconfig
@ -231,7 +231,7 @@ def similar_list(searchitem, searchlist, matchcount=1, searchorder='reverse'):
sim_num, sim_listitems = (list(x) for x in zip(*sorted(zip(sim_num, sim_listitems), key=itemgetter(0))))
if searchorder == 'reverse':
sim_listitems = spicemanip.main(sim_listitems, 'reverse', "list")
sim_listitems = spicemanip(sim_listitems, 'reverse', "list")
sim_listitems[-matchcount:]

View File

@ -1,7 +1,7 @@
# coding=utf8
from __future__ import unicode_literals, absolute_import, division, print_function
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
import re
from num2words import num2words
@ -21,10 +21,10 @@ class Translate():
for translationtype in translationtypes:
if translationtype == "hyphen":
totranslate = spicemanip.main(totranslate, 0).replace(' ', '-')
totranslate = spicemanip(totranslate, 0).replace(' ', '-')
elif translationtype == "underscore":
totranslate = spicemanip.main(totranslate, 0).replace(' ', '_')
totranslate = spicemanip(totranslate, 0).replace(' ', '_')
elif translationtype == "ermahgerd":
totranslate = self.trernslert(totranslate)
@ -42,10 +42,10 @@ class Translate():
totranslate = self.text_one_to_zero_swap(totranslate)
elif translationtype == "upper":
totranslate = spicemanip.main(totranslate, 0).upper()
totranslate = spicemanip(totranslate, 0).upper()
elif translationtype == "lower":
totranslate = spicemanip.main(totranslate, 0).lower()
totranslate = spicemanip(totranslate, 0).lower()
return totranslate
@ -66,7 +66,7 @@ class Translate():
else:
new_word = word[1:] + first + 'ay'
rebuildarray.append(new_word)
words = spicemanip.main(rebuildarray, 0)
words = spicemanip(rebuildarray, 0)
return words
def trernslert(self, werds):
@ -143,7 +143,7 @@ class Translate():
return "No input provided"
if not isinstance(words, list):
words = [words]
words = spicemanip.main(words, 0).split(" ")
words = spicemanip(words, 0).split(" ")
outputarray = []
for word in words:
if not self.isitbinary(word):
@ -152,7 +152,7 @@ class Translate():
word = str(word).replace('0', '1')
word = str(word).replace('2', '0')
outputarray.append(str(word))
outputarray = spicemanip.main(outputarray, 0)
outputarray = spicemanip(outputarray, 0)
return outputarray
def text_binary_swap(self, words):
@ -160,16 +160,16 @@ class Translate():
return "No input provided"
if not isinstance(words, list):
words = [words]
words = spicemanip.main(words, 0).split(" ")
words = spicemanip(words, 0).split(" ")
outputarray = []
for word in words:
if self.isitbinary(word):
word = self.bits2string(word) or 'error'
else:
word = self.string2bits(word) or 1
word = spicemanip.main(word, 0)
word = spicemanip(word, 0)
outputarray.append(str(word))
outputarray = spicemanip.main(outputarray, 0)
outputarray = spicemanip(outputarray, 0)
return outputarray
def unicode_string_cleanup(string):

View File

@ -8,7 +8,7 @@ from sopel.tools import Identifier
from .Database import db as botdb
from .Tools import is_number, inlist, similar, array_arrangesort
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
import threading
import re
@ -393,13 +393,13 @@ class BotUsers():
sim_num.append(similarlevel)
if sim_user != [] and sim_num != []:
sim_num, sim_user = array_arrangesort(bot, sim_num, sim_user)
closestmatch = spicemanip.main(sim_user, 'reverse', "list")
closestmatch = spicemanip(sim_user, 'reverse', "list")
listnumb, relist = 1, []
for item in closestmatch:
if listnumb <= 3:
relist.append(str(item))
listnumb += 1
closestmatches = spicemanip.main(relist, "andlist")
closestmatches = spicemanip(relist, "andlist")
targetgooderror = "It looks like you're trying to target someone! Did you mean: " + str(closestmatches) + "?"
else:
targetgooderror = "I am not sure who that is."
@ -437,7 +437,7 @@ class BotUsers():
if outputtype == 'list':
return validtargs
elif outputtype == 'random':
return spicemanip.main(validtargs, 'random')
return spicemanip(validtargs, 'random')
users = BotUsers()

View File

@ -6,7 +6,7 @@ import sopel.module
import sopel_modules.SpiceBot as SpiceBot
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
@SpiceBot.prerun('nickname')
@ -59,7 +59,7 @@ def bot_command_rule_ai(bot, trigger):
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.main(trigger_args, 0)
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']:
@ -73,7 +73,7 @@ def bot_command_rule_ai(bot, trigger):
command_type = 'module'
trigger_args, trigger_command, trigger_prefix = SpiceBot.make_trigger_args(message, 'module')
trigger_args.insert(0, trigger_command)
fulltrigger = spicemanip.main(trigger_args, 0)
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
@ -82,11 +82,11 @@ def bot_command_rule_ai(bot, trigger):
return
else:
command_type = 'other'
trigger_args = spicemanip.main(message, 'create')
trigger_args = spicemanip(message, 'create')
if not len(trigger_args):
return
trigger_command = trigger_args[0]
fulltrigger = spicemanip.main(trigger_args, 0)
fulltrigger = spicemanip(trigger_args, 0)
returnmessage = SpiceBot.botai.on_message(bot, trigger, fulltrigger)
if returnmessage:
@ -94,7 +94,7 @@ def bot_command_rule_ai(bot, trigger):
return
if command_type == 'nickname':
try_trigger = spicemanip.main(fulltrigger, "2+")
try_trigger = spicemanip(fulltrigger, "2+")
returnmessage = SpiceBot.botai.on_message(bot, trigger, try_trigger)
if returnmessage:
bot.osd(str(returnmessage))
@ -116,7 +116,7 @@ def bot_command_rule_ai(bot, trigger):
if trigger_args[0].lower() in ["what", "where"] and trigger_args[1].lower() in ["is", "are"]:
# TODO saved definitions
searchterm = spicemanip.main(trigger_args, "3+") or None
searchterm = spicemanip(trigger_args, "3+") or None
if searchterm:
if trigger_args[0].lower() == "where":
searchreturn = SpiceBot.google.search(searchterm, 'maps')
@ -132,7 +132,7 @@ def bot_command_rule_ai(bot, trigger):
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.main(trigger_args, "4+") or None
target = spicemanip(trigger_args, "4+") or None
if target:
if SpiceBot.inlist(trigger.nick, bot.users):
realtarget = SpiceBot.inlist_match(target, bot.users)
@ -141,7 +141,7 @@ def bot_command_rule_ai(bot, trigger):
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.main(targetchannels, 'andlist'))
dispmsg.append(realtarget + " is in " + spicemanip(targetchannels, 'andlist'))
bot.osd(dispmsg)
else:
bot.osd(trigger.nick + ", no. I cannot see " + target + " right now!")
@ -164,7 +164,7 @@ def bot_command_rule_ai(bot, trigger):
for nonjedi in [bot.nick, trigger.nick]:
if nonjedi in jedilist:
jedilist.remove(nonjedi)
jedi = spicemanip.main(jedilist, 'random')
jedi = spicemanip(jedilist, 'random')
if jedi:
bot.osd("turns to " + jedi + " and shoots him.", trigger.sender, 'action')
@ -183,7 +183,7 @@ def bot_command_rule_ai(bot, trigger):
return
elif fulltrigger.lower().startswith(tuple(["make me a", "beam me a"])):
makemea = spicemanip.main(trigger_args, "4+") or None
makemea = spicemanip(trigger_args, "4+") or None
if makemea:
bot.osd("beams " + trigger.nick + " a " + makemea, trigger.sender, 'action')
else:
@ -191,7 +191,7 @@ def bot_command_rule_ai(bot, trigger):
return
elif fulltrigger.lower().startswith("beam me to"):
location = spicemanip.main(trigger_args, "4+") or None
location = spicemanip(trigger_args, "4+") or None
if location:
bot.osd("locks onto " + trigger.nick + "s coordinates and transports them to " + location, 'action')
else:
@ -209,7 +209,7 @@ def bot_command_rule_ai(bot, trigger):
# TODO
# elif fulltrigger.lower().startswith(tuple(["have you seen"])):
# posstarget = spicemanip.main(trigger_args, 4) or 0
# posstarget = spicemanip(trigger_args, 4) or 0
# message = seen_search(bot, trigger, posstarget)
# bot.osd(message)
# return
@ -217,7 +217,7 @@ def bot_command_rule_ai(bot, trigger):
closestmatches = SpiceBot.similar_list(trigger_command, list(SpiceBot.commands.dict['commands']["nickname"].keys()), 3, 'reverse')
if len(closestmatches):
closestmatches = spicemanip.main(closestmatches, "andlist")
closestmatches = spicemanip(closestmatches, "andlist")
bot.osd("I don't know what you are asking me to do! Did you mean: " + str(closestmatches) + "?")
return
else:

View File

@ -4,7 +4,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel.module
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
import sopel_modules.SpiceBot as SpiceBot
@ -26,5 +26,5 @@ def bot_command_process(bot, trigger, botcom):
if not botcom.dict['com'].endswith("s"):
botcom.dict['com'] = str(botcom.dict['com'] + "s")
privlist = spicemanip.main(SpiceBot.bot_privs(botcom.dict['com']), 'andlist')
privlist = spicemanip(SpiceBot.bot_privs(botcom.dict['com']), 'andlist')
bot.osd(str(bot.nick) + " " + botcom.dict['com'] + ": " + privlist)

View File

@ -5,7 +5,7 @@ This is the SpiceBot Channels system.
"""
import sopel
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
import sopel_modules.SpiceBot as SpiceBot
@ -17,15 +17,15 @@ def nickname_comand_channels(bot, trigger, botcom):
if not len(botcom.dict['args']):
commandused = 'list'
else:
commandused = spicemanip.main(botcom.dict['args'], 1).lower()
commandused = spicemanip(botcom.dict['args'], 1).lower()
botcom.dict['args'] = spicemanip.main(botcom.dict['args'], '2+', 'list')
botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list')
if commandused == 'list':
botcount = len(list(bot.channels.keys()))
servercount = len(list(SpiceBot.channels.dict['list'].keys()))
displayval = "I am in " + str(botcount) + " of " + str(servercount) + " channel(s) available on this server."
chanlist = spicemanip.main(list(bot.channels.keys()), 'andlist')
chanlist = spicemanip(list(bot.channels.keys()), 'andlist')
bot.osd([displayval, "You can find me in " + chanlist])
return
@ -36,7 +36,7 @@ def nickname_comand_channels(bot, trigger, botcom):
return
elif commandused == 'random':
channel = spicemanip.main(SpiceBot.channels.dict['list'], 'random')
channel = spicemanip(SpiceBot.channels.dict['list'], 'random')
topic = SpiceBot.channels.dict['list'][channel]['topic']
msg = ["Random channel for you: {}.".format(SpiceBot.channels.dict['list'][channel]['name'])]
if topic and not topic.isspace():
@ -65,7 +65,7 @@ def nickname_comand_channels(bot, trigger, botcom):
if not len(botcom.dict['args']):
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Channel name input missing.")
return
channel = spicemanip.main(botcom.dict['args'], 1)
channel = spicemanip(botcom.dict['args'], 1)
if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())):
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Channel name {} not valid.".format(channel))
return
@ -82,7 +82,7 @@ def nickname_comand_channels(bot, trigger, botcom):
else:
channel = trigger.sender
else:
channel = spicemanip.main(botcom.dict['args'], 1)
channel = spicemanip(botcom.dict['args'], 1)
if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())):
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Channel name {} not valid.".format(channel))
return
@ -95,14 +95,14 @@ def nickname_comand_channels(bot, trigger, botcom):
if not len(privlist):
dispmsg.append("There are no Channel " + commandused.upper() + "s for " + str(channel))
else:
oplist = spicemanip.main(privlist, 'andlist')
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.main(botcom.dict['args'], 1)
channel = spicemanip(botcom.dict['args'], 1)
if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())):
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Channel name {} not valid.".format(channel))
return
@ -113,7 +113,7 @@ def nickname_comand_channels(bot, trigger, botcom):
if not len(list(bot.channels[channel].privileges.keys())):
dispmsg.append("There are no Channel users for " + str(channel))
else:
userslist = spicemanip.main(list(bot.channels[channel].privileges.keys()), 'andlist')
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

View File

@ -7,7 +7,7 @@ This Class stores commands in an easy to access manner
"""
import sopel
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
import sopel_modules.SpiceBot as SpiceBot
@ -21,7 +21,7 @@ def nickname_comand_commands(bot, trigger, botcom):
if not len(botcom.dict['args']):
commandused = 'list'
else:
commandused = spicemanip.main(botcom.dict['args'], 1).lower()
commandused = spicemanip(botcom.dict['args'], 1).lower()
if commandused == 'list':
availablecomsnum, availablecomsfiles = 0, []
@ -52,5 +52,5 @@ def nickname_comand_commands(bot, trigger, botcom):
return
if commandused == 'random':
bot.osd(["Here's a random command for you:", spicemanip.main(commands_list, 'random')])
bot.osd(["Here's a random command for you:", spicemanip(commands_list, 'random')])
return

View File

@ -7,7 +7,7 @@ This Class stores commands in an easy to access manner
"""
import sopel
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
import sopel_modules.SpiceBot as SpiceBot
@ -48,7 +48,7 @@ def query_detection_nick(bot, trigger, botcom):
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.main(closestmatches, 'andlist') + ".")
dispmsg.append("The following " + bot.nick + " commands match " + str(botcom.dict['com']) + ": " + spicemanip(closestmatches, 'andlist') + ".")
bot.osd(dispmsg, trigger.nick, 'notice')
return
@ -56,7 +56,7 @@ def query_detection_nick(bot, trigger, botcom):
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.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice')
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):
@ -69,7 +69,7 @@ def query_detection_nick(bot, trigger, botcom):
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.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice')
bot.osd("The following " + bot.nick + " commands may match " + str(botcom.dict['com']) + ": " + spicemanip(closestmatches, 'andlist') + ".", trigger.nick, 'notice')
return
commandlist = []
@ -80,7 +80,7 @@ def query_detection_nick(bot, trigger, botcom):
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.main(commandlist, 'andlist') + ".", trigger.nick, 'notice')
bot.osd("The following " + bot.nick + " commands start with " + str(botcom.dict['com']) + ": " + spicemanip(commandlist, 'andlist') + ".", trigger.nick, 'notice')
@SpiceBot.prerun_query('module', 'module')
@ -111,7 +111,7 @@ def query_detection(bot, trigger, botcom):
dispmsg = ["Cannot find any alias 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 commands match " + str(botcom.dict['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".")
dispmsg.append("The following commands match " + str(botcom.dict['com']) + ": " + spicemanip(closestmatches, 'andlist') + ".")
bot.osd(dispmsg, trigger.nick, 'notice')
return
@ -119,7 +119,7 @@ def query_detection(bot, trigger, botcom):
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 commands match " + str(botcom.dict['com']) + ": " + spicemanip.main(validcomlist, 'andlist') + ".", trigger.nick, 'notice')
bot.osd("The following commands match " + str(botcom.dict['com']) + ": " + spicemanip(validcomlist, 'andlist') + ".", trigger.nick, 'notice')
return
if botcom.dict['com'][:-1] == "?":
@ -132,7 +132,7 @@ def query_detection(bot, trigger, botcom):
if not len(closestmatches):
bot.osd("Cannot find any similar commands for " + str(botcom.dict['com']) + ".", trigger.nick, 'notice')
else:
bot.osd("The following commands may match " + str(botcom.dict['com']) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice')
bot.osd("The following commands may match " + str(botcom.dict['com']) + ": " + spicemanip(closestmatches, 'andlist') + ".", trigger.nick, 'notice')
return
commandlist = []
@ -143,4 +143,4 @@ def query_detection(bot, trigger, botcom):
if not len(commandlist):
bot.osd("No commands start with " + str(botcom.dict['com']) + ".", trigger.nick, 'notice')
else:
bot.osd("The following commands start with " + str(botcom.dict['com']) + ": " + spicemanip.main(commandlist, 'andlist') + ".", trigger.nick, 'notice')
bot.osd("The following commands start with " + str(botcom.dict['com']) + ": " + spicemanip(commandlist, 'andlist') + ".", trigger.nick, 'notice')

View File

@ -9,7 +9,7 @@ import sopel.module
import sopel_modules.SpiceBot as SpiceBot
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
from word2number import w2n
from random import randint
@ -34,13 +34,13 @@ def bot_dictcom_process(bot, trigger, botcom):
botcom.dict["responsekey"] = "?default"
# handling for special cases
posscom = spicemanip.main(botcom.dict['args'], 1)
posscom = spicemanip(botcom.dict['args'], 1)
if posscom.lower() in [command.lower() for command in botcom.dict["dict"].keys()]:
for command in botcom.dict["dict"].keys():
if command.lower() == posscom.lower():
posscom = command
botcom.dict["responsekey"] = posscom
botcom.dict['args'] = spicemanip.main(botcom.dict['args'], '2+', 'list')
botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list')
botcom.dict["dict"][botcom.dict["responsekey"]]["type"] = botcom.dict["dict"][botcom.dict["responsekey"]]["type"]
botcom.dict["nonstockoptions"] = []
@ -51,7 +51,7 @@ def bot_dictcom_process(bot, trigger, botcom):
# This allows users to specify which reply by number by using an ! and a digit (first or last in string)
validspecifides = ['last', 'random', 'count', 'view', 'add', 'del', 'remove', 'special']
botcom.dict["specified"] = None
argone = spicemanip.main(botcom.dict['args'], 1)
argone = spicemanip(botcom.dict['args'], 1)
if str(argone).startswith("--") and len(str(argone)) > 2:
if str(argone[2:]).isdigit():
botcom.dict["specified"] = int(argone[2:])
@ -67,7 +67,7 @@ def bot_dictcom_process(bot, trigger, botcom):
except ValueError:
botcom.dict["specified"] = None
if botcom.dict["specified"]:
botcom.dict['args'] = spicemanip.main(botcom.dict['args'], '2+', 'list')
botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list')
# commands that can be updated
if botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]:
@ -79,7 +79,7 @@ def bot_dictcom_process(bot, trigger, botcom):
botcom.dict["dict"][botcom.dict["responsekey"]]["responses"] = SpiceBot.db.get_nick_value(str(trigger.nick), botcom.dict["dict"]["validcoms"][0] + "_" + str(botcom.dict["responsekey"]), 'sayings') or []
if botcom.dict["specified"] == 'special':
nonstockoptions = spicemanip.main(botcom.dict["nonstockoptions"], "andlist")
nonstockoptions = spicemanip(botcom.dict["nonstockoptions"], "andlist")
return bot.osd("The special options for " + str(botcom.dict["realcom"]) + " command include: " + str(nonstockoptions) + ".")
elif botcom.dict["specified"] == 'count':
@ -106,7 +106,7 @@ def bot_dictcom_process(bot, trigger, botcom):
if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]:
return bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list cannot be updated.")
fulltext = spicemanip.main(botcom.dict['args'], 0)
fulltext = spicemanip(botcom.dict['args'], 0)
if not fulltext:
return bot.osd("What would you like to add to the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?")
@ -125,7 +125,7 @@ def bot_dictcom_process(bot, trigger, botcom):
if not botcom.dict["dict"][botcom.dict["responsekey"]]["updates_enabled"]:
return bot.osd("The " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list cannot be updated.")
fulltext = spicemanip.main(botcom.dict['args'], 0)
fulltext = spicemanip(botcom.dict['args'], 0)
if not fulltext:
return bot.osd("What would you like to remove from the " + str(botcom.dict["realcom"]) + " " + str(botcom.dict["responsekey"] or '') + " entry list?")
@ -161,7 +161,7 @@ def bot_dictcom_responses(bot, trigger, botcom):
if botcom.dict["dict"][botcom.dict["responsekey"]]["target_required"]:
# try first term as a target
posstarget = spicemanip.main(botcom.dict['args'], 1) or 0
posstarget = spicemanip(botcom.dict['args'], 1) or 0
targetbypass = botcom.dict["dict"][botcom.dict["responsekey"]]["target_bypass"]
targetchecking = SpiceBot.users.target_check(bot, trigger, posstarget, targetbypass)
if not targetchecking["targetgood"]:
@ -180,11 +180,11 @@ def bot_dictcom_responses(bot, trigger, botcom):
if not reaction:
commandrunconsensus.append([targetchecking["error"]])
else:
botcom.dict["target"] = spicemanip.main(botcom.dict['args'], 1)
botcom.dict['args'] = spicemanip.main(botcom.dict['args'], '2+', 'list')
botcom.dict["target"] = spicemanip(botcom.dict['args'], 1)
botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list')
# $blank input
botcom.dict["completestring"] = spicemanip.main(botcom.dict['args'], 0) or ''
botcom.dict["completestring"] = spicemanip(botcom.dict['args'], 0) or ''
if botcom.dict["dict"][botcom.dict["responsekey"]]["blank_required"]:
if botcom.dict["completestring"] == '' or not botcom.dict["completestring"]:
@ -196,13 +196,13 @@ def bot_dictcom_responses(bot, trigger, botcom):
if botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"]:
if botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"] != []:
if spicemanip.main(botcom.dict["completestring"], 1).lower() not in botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"]:
if spicemanip(botcom.dict["completestring"], 1).lower() not in botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"]:
botcom.dict["completestring"] = botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"][0] + " " + botcom.dict["completestring"]
elif spicemanip.main(botcom.dict["completestring"], 1).lower() in botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"]:
if spicemanip.main(botcom.dict["completestring"], 1).lower() != botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"][0]:
botcom.dict['args'] = spicemanip.main(botcom.dict['args'], '2+', 'list')
elif spicemanip(botcom.dict["completestring"], 1).lower() in botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"]:
if spicemanip(botcom.dict["completestring"], 1).lower() != botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"][0]:
botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list')
if botcom.dict['args'] != []:
botcom.dict["completestring"] = botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"][0] + " " + spicemanip.main(botcom.dict['args'], 0)
botcom.dict["completestring"] = botcom.dict["dict"][botcom.dict["responsekey"]]["blank_phrasehandle"][0] + " " + spicemanip(botcom.dict['args'], 0)
if commandrunconsensus != []:
botcom.dict["success"] = False
@ -221,10 +221,10 @@ def bot_dictcom_reply_shared(bot, trigger, botcom):
currentspecified = len(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"])
else:
currentspecified = botcom.dict["specified"]
botcom.dict["replies"] = spicemanip.main(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"], currentspecified, 'return')
botcom.dict["replies"] = spicemanip(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"], currentspecified, 'return')
botcom.dict["replynum"] = currentspecified
else:
botcom.dict["replies"] = spicemanip.main(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"], 'random', 'return')
botcom.dict["replies"] = spicemanip(botcom.dict["dict"][botcom.dict["responsekey"]]["responses"], 'random', 'return')
try:
botcom.dict["replynum"] = botcom.dict["dict"][botcom.dict["responsekey"]]["responses"].index(botcom.dict["replies"])
except Exception as e:
@ -258,7 +258,7 @@ def bot_dictcom_reply_shared(bot, trigger, botcom):
# the remaining input
if "$input" in rply:
rply = rply.replace("$input", spicemanip.main(botcom.dict['args'], 0) or botcom.dict["realcom"])
rply = rply.replace("$input", spicemanip(botcom.dict['args'], 0) or botcom.dict["realcom"])
# translation
if botcom.dict["dict"][botcom.dict["responsekey"]]["translations"]:
@ -266,11 +266,11 @@ def bot_dictcom_reply_shared(bot, trigger, botcom):
# text to precede the output
if botcom.dict["dict"][botcom.dict["responsekey"]]["prefixtext"] and botcom.dict["success"]:
rply = spicemanip.main(botcom.dict["dict"][botcom.dict["responsekey"]]["prefixtext"], 'random') + rply
rply = spicemanip(botcom.dict["dict"][botcom.dict["responsekey"]]["prefixtext"], 'random') + rply
# text to follow the output
if botcom.dict["dict"][botcom.dict["responsekey"]]["suffixtext"] and botcom.dict["success"]:
rply = rply + spicemanip.main(botcom.dict["dict"][botcom.dict["responsekey"]]["suffixtext"], 'random')
rply = rply + spicemanip(botcom.dict["dict"][botcom.dict["responsekey"]]["suffixtext"], 'random')
# trigger.nick
if "$instigator" in rply:
@ -279,7 +279,7 @@ def bot_dictcom_reply_shared(bot, trigger, botcom):
# random user
if "$randuser" in rply:
if not trigger.is_privmsg:
randuser = spicemanip.main(SpiceBot.users.random_valid_target(trigger, 'random'))
randuser = spicemanip(SpiceBot.users.random_valid_target(trigger, 'random'))
else:
randuser = trigger.nick
rply = rply.replace("$randuser", randuser)
@ -310,7 +310,7 @@ def bot_dictcom_reply_shared(bot, trigger, botcom):
# smaller variations for the text
if "$replyvariation" in rply:
if botcom.dict["dict"][botcom.dict["responsekey"]]["replyvariation"] != []:
variation = spicemanip.main(botcom.dict["dict"][botcom.dict["responsekey"]]["replyvariation"], 'random')
variation = spicemanip(botcom.dict["dict"][botcom.dict["responsekey"]]["replyvariation"], 'random')
rply = rply.replace("$replyvariation", variation)
else:
rply = rply.replace("$replyvariation", '')
@ -328,7 +328,7 @@ def bot_dictcom_reply_shared(bot, trigger, botcom):
for command in botcom.dict["dict"].keys():
if command not in ["?default", "validcoms", "contributors", "author", "type", "filepath", "filename", "hardcoded_channel_block", "description", "exampleresponse", "example", "usage", "privs"]:
nonstockoptions.append(command)
nonstockoptions = spicemanip.main(nonstockoptions, "andlist")
nonstockoptions = spicemanip(nonstockoptions, "andlist")
rply = rply.replace("$specialoptions", nonstockoptions)
# saying, or action?
@ -360,9 +360,9 @@ def bot_dictcom_gif(bot, trigger, botcom):
if botcom.dict["specified"]:
if botcom.dict["specified"] > len(queries):
botcom.dict["specified"] = len(queries)
query = spicemanip.main(queries, botcom.dict["specified"], 'return')
query = spicemanip(queries, botcom.dict["specified"], 'return')
else:
query = spicemanip.main(queries, 'random', 'return')
query = spicemanip(queries, 'random', 'return')
searchdict = {"query": query, "gifsearch": searchapis}

View File

@ -6,7 +6,7 @@ import sopel.module
import sopel_modules.SpiceBot as SpiceBot
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
# TODO custom gif shortcut commands
@ -18,7 +18,7 @@ def gif_trigger(bot, trigger, botcom):
if not len(botcom.dict['args']):
return SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Please present a query to search.")
query = spicemanip.main(botcom.dict['args'], 0)
query = spicemanip(botcom.dict['args'], 0)
searchapis = list(SpiceBot.gif.valid_api.keys())
searchdict = {"query": query, "gifsearch": searchapis}
@ -40,7 +40,7 @@ def gifapi_triggers(bot, trigger, botcom):
if not len(botcom.dict['args']):
return SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Please present a query to search.")
query = spicemanip.main(botcom.dict['args'], 0)
query = spicemanip(botcom.dict['args'], 0)
searchdict = {"query": query, "gifsearch": botcom.dict['com']}
gifdict = SpiceBot.gif.get_gif(searchdict)

View File

@ -7,7 +7,7 @@ This is the SpiceBot Logs System
# sopel imports
import sopel.module
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
import sopel_modules.SpiceBot as SpiceBot
@ -20,9 +20,9 @@ def bot_command_logs(bot, trigger, botcom):
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "I was unable to process this Bot Nick command due to privilege issues.")
return
logtype = spicemanip.main(botcom.dict['args'], 1) or None
logtype = spicemanip(botcom.dict['args'], 1) or None
if not logtype:
bot.osd("Current valid log(s) include: " + spicemanip.main(list(SpiceBot.logs.dict["list"].keys()), 'andlist'), trigger.sender, 'action')
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())):
@ -30,7 +30,7 @@ def bot_command_logs(bot, trigger, botcom):
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.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice')
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "The following commands may match " + str(logtype) + ": " + spicemanip(closestmatches, 'andlist') + ".", trigger.nick, 'notice')
return

View File

@ -4,7 +4,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel.module
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
import sopel_modules.SpiceBot as SpiceBot
@ -40,14 +40,14 @@ def bot_command_process(bot, trigger, botcom):
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "You must specify a channel or nick.")
return
target = spicemanip.main(botcom.dict['args'], 1)
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.main(botcom.dict['args'], '2+', 'list')
botcom.dict['args'] = spicemanip(botcom.dict['args'], '2+', 'list')
if target == 'allchans':
targetsendlist = list(bot.channels.keys())
@ -56,7 +56,7 @@ def bot_command_process(bot, trigger, botcom):
else:
targetsendlist = [target]
botmessage = spicemanip.main(botcom.dict['args'], 0)
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

View File

@ -4,7 +4,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
import sopel.module
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
import sopel_modules.SpiceBot as SpiceBot
@ -20,13 +20,13 @@ def nickname_comand_update(bot, trigger, botcom):
if not len(botcom.dict['args']):
commandused = 'nodeps'
else:
commandused = spicemanip.main(botcom.dict['args'], 1).lower()
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.main(botcom.dict['args'], '2+', 'list')
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)

View File

@ -5,7 +5,7 @@ This is the SpiceBot search system.
"""
import sopel
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
import sopel_modules.SpiceBot as SpiceBot
@ -14,7 +14,7 @@ import sopel_modules.SpiceBot as SpiceBot
@sopel.module.commands('search', 'find', 'google', 'lookup')
def search_main(bot, trigger, botcom):
searchterm = spicemanip.main(botcom.dict['args'], 0) or None
searchterm = spicemanip(botcom.dict['args'], 0) or None
if not searchterm:
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Not sure what you want me to look for.")
return
@ -30,7 +30,7 @@ def search_main(bot, trigger, botcom):
@sopel.module.commands("where", "whereis")
def search_where(bot, trigger, botcom):
searchterm = spicemanip.main(botcom.dict['args'], 0) or None
searchterm = spicemanip(botcom.dict['args'], 0) or None
if not searchterm:
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Not sure what you want me to look for.")
return
@ -46,7 +46,7 @@ def search_where(bot, trigger, botcom):
@sopel.module.commands("what", "whatis")
def search_what(bot, trigger, botcom):
searchterm = spicemanip.main(botcom.dict['args'], 0) or None
searchterm = spicemanip(botcom.dict['args'], 0) or None
if not searchterm:
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Not sure what you want me to look for.")
return
@ -62,7 +62,7 @@ def search_what(bot, trigger, botcom):
@sopel.module.commands("youtube", "video")
def search_video(bot, trigger, botcom):
searchterm = spicemanip.main(botcom.dict['args'], 0) or None
searchterm = spicemanip(botcom.dict['args'], 0) or None
if not searchterm:
SpiceBot.messagelog.messagelog_error(botcom.dict["log_id"], "Not sure what you want me to look for.")
return

View File

@ -4,7 +4,7 @@ from __future__ import unicode_literals, absolute_import, division, print_functi
# sopel imports
import sopel.module
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
import sopel_modules.SpiceBot as SpiceBot
@ -15,15 +15,15 @@ def bot_command_sherlock(bot, trigger, botcom):
netlist = list(SpiceBot.sherlock.dict.keys())
username = spicemanip.main(botcom.dict["args"], 1) or trigger.nick
botcom.dict["args"] = spicemanip.main(botcom.dict["args"], "2+", 'list')
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.main(botcom.dict["args"], 1) or trigger.nick
username = spicemanip(botcom.dict["args"], 1) or trigger.nick
bot.osd("Checking username " + username + " in " + checklistname + " network.")
@ -41,9 +41,9 @@ def bot_command_sherlock(bot, trigger, botcom):
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.main(inlist, "andlist")], trigger.nick, 'NOTICE')
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.main(notinlist, "andlist")])
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.main(notinlist, "andlist")], trigger.nick, 'NOTICE')
bot.osd(["The username " + username + " is NOT in the following:", spicemanip(notinlist, "andlist")], trigger.nick, 'NOTICE')

View File

@ -7,7 +7,7 @@ import sopel
import time
import sopel_modules.spicemanip as spicemanip
from sopel_modules.spicemanip import spicemanip
import sopel_modules.SpiceBot as SpiceBot
@ -86,7 +86,7 @@ def trigger_channel_list_recurring(bot, trigger):
if "*" in newlist:
newlist.remove("*")
if len(newlist) and SpiceBot.config.SpiceBot_Channels.announcenew:
bot.osd(["The Following channel(s) are new:", spicemanip.main(newlist, 'andlist')], list(bot.channels.keys()))
bot.osd(["The Following channel(s) are new:", spicemanip(newlist, 'andlist')], list(bot.channels.keys()))
SpiceBot.channels.join_all_channels(bot)

View File

@ -336,351 +336,4 @@ class Spicemanip():
return False
main = Spicemanip()
# Hub
def core(inputs, outputtask, output_type='default'):
mainoutputtask, suboutputtask = None, None
# Input needs to be a list, but don't split a word into letters
if not inputs:
inputs = []
if isinstance(inputs, collections.abc.KeysView):
inputs = list(inputs)
elif isinstance(inputs, dict):
inputs = list(inputs.keys())
if not isinstance(inputs, list):
inputs = list(inputs.split(" "))
inputs = [x for x in inputs if x and x not in ['', ' ']]
inputs = [inputspart.strip() for inputspart in inputs]
# Create return
if outputtask == 'create':
return inputs
# Make temparray to preserve original order
temparray = []
for inputpart in inputs:
temparray.append(inputpart)
inputs = temparray
# Convert outputtask to standard
if outputtask in [0, 'complete']:
outputtask = 'string'
elif outputtask == 'index':
mainoutputtask = inputs[1]
suboutputtask = inputs[2]
inputs = inputs[0]
elif str(outputtask).isdigit():
mainoutputtask, outputtask = int(outputtask), 'number'
elif "^" in str(outputtask):
mainoutputtask = str(outputtask).split("^", 1)[0]
suboutputtask = str(outputtask).split("^", 1)[1]
outputtask = 'rangebetween'
if int(suboutputtask) < int(mainoutputtask):
mainoutputtask, suboutputtask = suboutputtask, mainoutputtask
elif str(outputtask).startswith("split_"):
mainoutputtask = str(outputtask).replace("split_", "")
outputtask = 'split'
elif str(outputtask).endswith(tuple(["!", "+", "-", "<", ">"])):
mainoutputtask = str(outputtask)
if str(outputtask).endswith("!"):
outputtask = 'exclude'
if str(outputtask).endswith("+"):
outputtask = 'incrange_plus'
if str(outputtask).endswith("-"):
outputtask = 'incrange_minus'
if str(outputtask).endswith(">"):
outputtask = 'excrange_plus'
if str(outputtask).endswith("<"):
outputtask = 'excrange_minus'
for r in (("!", ""), ("+", ""), ("-", ""), ("<", ""), (">", "")):
mainoutputtask = mainoutputtask.replace(*r)
if mainoutputtask == 'last':
mainoutputtask = len(inputs)
if outputtask == 'string':
returnvalue = inputs
else:
returnvalue = eval(
'spicemanip_' + outputtask +
'(inputs, outputtask, mainoutputtask, suboutputtask)')
# default return if not specified
if output_type == 'default':
if outputtask in [
'string', 'number', 'rangebetween', 'exclude', 'random',
'incrange_plus', 'incrange_minus', 'excrange_plus',
'excrange_minus'
]:
output_type = 'string'
elif outputtask in ['count']:
output_type = 'dict'
# verify output is correct
if output_type == 'return':
return returnvalue
if output_type == 'string':
if isinstance(returnvalue, list):
returnvalue = ' '.join(returnvalue)
elif output_type in ['list', 'array']:
if not isinstance(returnvalue, list):
returnvalue = list(returnvalue.split(" "))
returnvalue = [x for x in returnvalue if x and x not in ['', ' ']]
returnvalue = [inputspart.strip() for inputspart in returnvalue]
return returnvalue
# compare 2 lists, based on the location of an index item, passthrough needs to be [indexitem, arraytoindex, arraytocompare]
def spicemanip_index(indexitem, outputtask, arraytoindex, arraytocompare):
item = ''
for x, y in zip(arraytoindex, arraytocompare):
if x == indexitem:
item = y
return item
# split list by string
def spicemanip_split(inputs, outputtask, mainoutputtask, suboutputtask):
split_array = []
restring = ' '.join(inputs)
if mainoutputtask not in inputs:
split_array = [restring]
else:
split_array = restring.split(mainoutputtask)
split_array = [x for x in split_array if x and x not in ['', ' ']]
split_array = [inputspart.strip() for inputspart in split_array]
if split_array == []:
split_array = [[]]
return split_array
# dedupe list
def spicemanip_dedupe(inputs, outputtask, mainoutputtask, suboutputtask):
newlist = []
for inputspart in inputs:
if inputspart not in newlist:
newlist.append(inputspart)
return newlist
# Sort list
def spicemanip_sort(inputs, outputtask, mainoutputtask, suboutputtask):
return sorted(inputs)
# reverse sort list
def spicemanip_rsort(inputs, outputtask, mainoutputtask, suboutputtask):
return sorted(inputs)[::-1]
# count items in list, return dictionary
def spicemanip_count(inputs, outputtask, mainoutputtask, suboutputtask):
returndict = dict()
if not len(inputs):
return returndict
uniqueinputitems, uniquecount = [], []
for inputspart in inputs:
if inputspart not in uniqueinputitems:
uniqueinputitems.append(inputspart)
for uniqueinputspart in uniqueinputitems:
count = 0
for ele in inputs:
if (ele == uniqueinputspart):
count += 1
uniquecount.append(count)
for inputsitem, unumber in zip(uniqueinputitems, uniquecount):
returndict[inputsitem] = unumber
return returndict
# random item from list
def spicemanip_random(inputs, outputtask, mainoutputtask, suboutputtask):
if not len(inputs):
return ''
randomselectlist = []
for temppart in inputs:
randomselectlist.append(temppart)
while len(randomselectlist) > 1:
random.shuffle(randomselectlist)
randomselect = randomselectlist[random.randint(
0,
len(randomselectlist) - 1)]
randomselectlist.remove(randomselect)
randomselect = randomselectlist[0]
return randomselect
# remove random item from list
def spicemanip_exrandom(inputs, outputtask, mainoutputtask, suboutputtask):
if not len(inputs):
return []
randremove = spicemanip_random(inputs, outputtask, mainoutputtask,
suboutputtask)
inputs.remove(randremove)
return inputs
# Convert list into lowercase
def spicemanip_lower(inputs, outputtask, mainoutputtask, suboutputtask):
if not len(inputs):
return ''
return [inputspart.lower() for inputspart in inputs]
# Convert list to uppercase
def spicemanip_upper(inputs, outputtask, mainoutputtask, suboutputtask):
if not len(inputs):
return ''
return [inputspart.upper() for inputspart in inputs]
# Convert list to uppercase
def spicemanip_title(inputs, outputtask, mainoutputtask, suboutputtask):
if not len(inputs):
return ''
return [inputspart.title() for inputspart in inputs]
# Reverse List Order
def spicemanip_reverse(inputs, outputtask, mainoutputtask, suboutputtask):
if not len(inputs):
return []
return inputs[::-1]
# comma seperated list
def spicemanip_list(inputs, outputtask, mainoutputtask, suboutputtask):
if not len(inputs):
return ''
return ', '.join(str(x) for x in inputs)
def spicemanip_list_nospace(inputs, outputtask, mainoutputtask, suboutputtask):
if not len(inputs):
return ''
return ','.join(str(x) for x in inputs)
# comma seperated list with and
def spicemanip_andlist(inputs, outputtask, mainoutputtask, suboutputtask):
if not len(inputs):
return ''
if len(inputs) < 2:
return ' '.join(inputs)
lastentry = str("and " + str(inputs[len(inputs) - 1]))
del inputs[-1]
inputs.append(lastentry)
if len(inputs) == 2:
return ' '.join(inputs)
return ', '.join(str(x) for x in inputs)
# comma seperated list with or
def spicemanip_orlist(inputs, outputtask, mainoutputtask, suboutputtask):
if not len(inputs):
return ''
if len(inputs) < 2:
return ' '.join(inputs)
lastentry = str("or " + str(inputs[len(inputs) - 1]))
del inputs[-1]
inputs.append(lastentry)
if len(inputs) == 2:
return ' '.join(inputs)
return ', '.join(str(x) for x in inputs)
# exclude number
def spicemanip_exclude(inputs, outputtask, mainoutputtask, suboutputtask):
if not len(inputs):
return ''
del inputs[int(mainoutputtask) - 1]
return ' '.join(inputs)
# Convert list to string
def spicemanip_string(inputs, outputtask, mainoutputtask, suboutputtask):
if not len(inputs):
return ''
return ' '.join(inputs)
# Get number item from list
def spicemanip_number(inputs, outputtask, mainoutputtask, suboutputtask):
if not len(inputs):
return ''
elif len(inputs) == 1:
return inputs[0]
elif int(mainoutputtask) > len(inputs) or int(mainoutputtask) < 0:
return ''
else:
return inputs[int(mainoutputtask) - 1]
# Get Last item from list
def spicemanip_last(inputs, outputtask, mainoutputtask, suboutputtask):
if not len(inputs):
return ''
return inputs[len(inputs) - 1]
# range between items in list
def spicemanip_rangebetween(inputs, outputtask, mainoutputtask, suboutputtask):
if not len(inputs):
return ''
if not str(mainoutputtask).isdigit() or not str(suboutputtask).isdigit():
return ''
mainoutputtask, suboutputtask = int(mainoutputtask), int(suboutputtask)
if suboutputtask == mainoutputtask:
return spicemanip_number(inputs, outputtask, mainoutputtask,
suboutputtask)
if suboutputtask < mainoutputtask:
return []
if mainoutputtask < 0:
mainoutputtask = 1
if suboutputtask > len(inputs):
suboutputtask = len(inputs)
newlist = []
for i in range(mainoutputtask, suboutputtask + 1):
newlist.append(
str(spicemanip_number(inputs, outputtask, i, suboutputtask)))
if newlist == []:
return ''
return ' '.join(newlist)
# Forward Range includes index number
def spicemanip_incrange_plus(inputs, outputtask, mainoutputtask,
suboutputtask):
if not len(inputs):
return ''
return spicemanip_rangebetween(inputs, outputtask, int(mainoutputtask),
len(inputs))
# Reverse Range includes index number
def spicemanip_incrange_minus(inputs, outputtask, mainoutputtask,
suboutputtask):
if not len(inputs):
return ''
return spicemanip_rangebetween(inputs, outputtask, 1, int(mainoutputtask))
# Forward Range excludes index number
def spicemanip_excrange_plus(inputs, outputtask, mainoutputtask,
suboutputtask):
if not len(inputs):
return ''
return spicemanip_rangebetween(inputs, outputtask,
int(mainoutputtask) + 1, len(inputs))
# Reverse Range excludes index number
def spicemanip_excrange_minus(inputs, outputtask, mainoutputtask,
suboutputtask):
if not len(inputs):
return ''
return spicemanip_rangebetween(inputs, outputtask, 1,
int(mainoutputtask) - 1)
spicemanip = Spicemanip()