Merge pull request #78 from deathbybandaid/development

Development
This commit is contained in:
Deathbybandaid 2019-06-28 17:00:51 -04:00 committed by GitHub
commit c7c9ead4bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 206 additions and 152 deletions

View File

@ -21,6 +21,7 @@ from .Config import config as botconfig
from .Database import db as botdb from .Database import db as botdb
from .Read import read as botread from .Read import read as botread
from .Channels import channels as botchannels from .Channels import channels as botchannels
from .Users import users as botusers
class SpiceBot_Commands_MainSection(StaticSection): class SpiceBot_Commands_MainSection(StaticSection):
@ -91,72 +92,89 @@ class BotCommands():
return realcom return realcom
def chan_or_nick(self, target):
if botchannels.check_channel_bot(target, True):
return "channel"
elif botdb.check_nick_id(target):
return "nick"
else:
raise Exception(str(target.lower()) + " appears to not be a valid user/channel")
def get_commands_disabled(self, target, disabletype="fully"): def get_commands_disabled(self, target, disabletype="fully"):
disabletype = str(disabletype) disabletype = str(disabletype)
target_type = self.chan_or_nick(target)
if disabletype not in list(self.dict['disabled'].keys()): if disabletype not in list(self.dict['disabled'].keys()):
self.dict['disabled'][disabletype] = { self.dict['disabled'][disabletype] = {
"users": {}, "nick": {},
"channels": {} "channel": {}
} }
if botdb.check_nick_id(target): if target_type == "nick":
if not len(list(self.dict['disabled'][disabletype]["users"])): nick_id = botusers.ID(target)
self.dict['disabled'][disabletype]["users"] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {} if nick_id not in list(self.dict['disabled'][disabletype]["nick"].keys()):
return self.dict['disabled'][disabletype]["users"] self.dict['disabled'][disabletype]["nick"][nick_id] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {}
elif botchannels.check_channel_bot(target, True): return self.dict['disabled'][disabletype]["nick"][nick_id]
if not len(list(self.dict['disabled'][disabletype]["channels"])): elif target_type == "channel":
self.dict['disabled'][disabletype]["channels"] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} target = str(target).lower()
return self.dict['disabled'][disabletype]["channels"] if target not in list(self.dict['disabled'][disabletype]["channel"].keys()):
self.dict['disabled'][disabletype]["channel"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {}
return self.dict['disabled'][disabletype]["channel"][target]
else: else:
raise Exception(str(target.lower()) + " appears to not be a valid user/channel") raise Exception(str(target.lower()) + " appears to not be a valid user/channel")
def check_commands_disabled(self, command, target, disabletype="fully"): def check_commands_disabled(self, command, target, disabletype="fully"):
if disabletype not in list(self.dict['disabled'].keys()): command = str(command).lower()
self.dict['disabled'][disabletype] = {
"users": {},
"channels": {}
}
if command in list(self.get_commands_disabled(target, disabletype).keys()): if command in list(self.get_commands_disabled(target, disabletype).keys()):
return True return True
else: else:
return False return False
def set_command_disabled(self, command, target, timestamp, reason, bywhom, disabletype="fully"): def set_command_disabled(self, command, target, timestamp, reason, bywhom, disabletype="fully"):
command = str(command).lower()
disabletype = str(disabletype)
target_type = self.chan_or_nick(target)
if disabletype not in list(self.dict['disabled'].keys()): if disabletype not in list(self.dict['disabled'].keys()):
self.dict['disabled'][disabletype] = { self.dict['disabled'][disabletype] = {
"users": {}, "nick": {},
"channels": {} "channel": {}
} }
if botdb.check_nick_id(target): if target_type == "nick":
if not len(list(self.dict['disabled'][disabletype]["users"])): nick_id = botusers.ID(target)
self.dict['disabled'][disabletype]["users"] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {} if nick_id not in list(self.dict['disabled'][disabletype]["nick"].keys()):
self.dict['disabled'][disabletype]["users"][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom} self.dict['disabled'][disabletype]["nick"][nick_id] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {}
botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["users"]) self.dict['disabled'][disabletype]["nick"][nick_id][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom}
elif botchannels.check_channel_bot(target, True): botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["nick"][nick_id])
if not len(list(self.dict['disabled'][disabletype]["channels"])): elif target_type == "channel":
self.dict['disabled'][disabletype]["channels"] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} target = str(target).lower()
self.dict['disabled'][disabletype]["channels"][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom} if target not in list(self.dict['disabled'][disabletype]["channel"].keys()):
botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channels"]) self.dict['disabled'][disabletype]["channel"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {}
self.dict['disabled'][disabletype]["channel"][target][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom}
botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channel"][target])
else: else:
raise Exception(str(target.lower()) + " appears to not be a valid user/channel") raise Exception(str(target.lower()) + " appears to not be a valid user/channel")
def unset_command_disabled(self, command, target, disabletype="fully"): def unset_command_disabled(self, command, target, disabletype="fully"):
command = str(command).lower()
disabletype = str(disabletype)
target_type = self.chan_or_nick(target)
if disabletype not in list(self.dict['disabled'].keys()): if disabletype not in list(self.dict['disabled'].keys()):
self.dict['disabled'][disabletype] = { self.dict['disabled'][disabletype] = {
"users": {}, "nick": {},
"channels": {} "channel": {}
} }
if botdb.check_nick_id(target): if target_type == "nick":
if not len(list(self.dict['disabled'][disabletype]["users"])): nick_id = botusers.ID(target)
self.dict['disabled'][disabletype]["users"] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {} if nick_id not in list(self.dict['disabled'][disabletype]["nick"].keys()):
if command in list(self.dict['disabled'][disabletype]["users"].keys()): self.dict['disabled'][disabletype]["nick"][nick_id] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {}
del self.dict['disabled'][disabletype]["users"][command] if command in list(self.dict['disabled'][disabletype]["nick"][nick_id].keys()):
botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["users"]) del self.dict['disabled'][disabletype]["nick"][nick_id][command]
elif botchannels.check_channel_bot(target, True): botdb.set_nick_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["nick"][nick_id])
if not len(list(self.dict['disabled'][disabletype]["channels"])): elif target_type == "channel":
self.dict['disabled'][disabletype]["channels"] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {} target = str(target).lower()
if command in list(self.dict['disabled'][disabletype]["channels"].keys()): if target not in list(self.dict['disabled'][disabletype]["channel"].keys()):
del self.dict['disabled'][disabletype]["channels"][command] self.dict['disabled'][disabletype]["nick"][target] = botdb.get_channel_value(target, 'commands_' + disabletype + 'disabled') or {}
botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channels"]) if command in list(self.dict['disabled'][disabletype]["channel"][target].keys()):
del self.dict['disabled'][disabletype]["channel"][target][command]
botdb.set_channel_value(target, 'commands_' + disabletype + 'disabled', self.dict['disabled'][disabletype]["channel"][target])
else: else:
raise Exception(str(target.lower()) + " appears to not be a valid user/channel") raise Exception(str(target.lower()) + " appears to not be a valid user/channel")

View File

@ -39,7 +39,7 @@ class MessageLog():
self.error_message_dict[unique_id] = errormsg self.error_message_dict[unique_id] = errormsg
return unique_id return unique_id
def messagelog_start(self, bot, trigger, log_id): def messagelog_start(self, bot, trigger, log_id, commandname):
if not trigger.is_privmsg: if not trigger.is_privmsg:
channelname = trigger.sender channelname = trigger.sender
@ -55,6 +55,7 @@ class MessageLog():
"nick": bot.nick "nick": bot.nick
}, },
"messages": [], "messages": [],
"commandname": commandname,
} }
def messagelog_error(self, log_id, error_id): def messagelog_error(self, log_id, error_id):

View File

@ -12,12 +12,13 @@ import datetime
import spicemanip import spicemanip
from .Tools import command_permissions_check from .Tools import command_permissions_check, class_create
from .Commands import commands as botcommands from .Commands import commands as botcommands
from .Database import db as botdb from .Database import db as botdb
from .Channels import channels as botchannels from .Channels import channels as botchannels
from .MessageLog import messagelog as botmessagelog from .MessageLog import messagelog as botmessagelog
from .Config import config as botconfig from .Config import config as botconfig
from .Users import users as botusers
def prerun(t_command_type='module', t_command_subtype=None): def prerun(t_command_type='module', t_command_subtype=None):
@ -27,6 +28,8 @@ def prerun(t_command_type='module', t_command_subtype=None):
@functools.wraps(function) @functools.wraps(function)
def internal_prerun(bot, trigger, *args, **kwargs): def internal_prerun(bot, trigger, *args, **kwargs):
botcom = class_create('botcom')
if t_command_type == "nickname": if t_command_type == "nickname":
check_nick = spicemanip.main(trigger.args[1], 1).lower() check_nick = spicemanip.main(trigger.args[1], 1).lower()
if check_nick != str(bot.nick).lower(): if check_nick != str(bot.nick).lower():
@ -79,7 +82,7 @@ def prerun(t_command_type='module', t_command_subtype=None):
argsdict_list = trigger_argsdict_list(argsdict_default, and_split) argsdict_list = trigger_argsdict_list(argsdict_default, and_split)
# Run the function for all splits # Run the function for all splits
botmessagelog.messagelog_start(bot, trigger, argsdict_default["log_id"]) botmessagelog.messagelog_start(bot, trigger, argsdict_default["log_id"], argsdict_default["realcomtext"])
runcount = 0 runcount = 0
for argsdict in argsdict_list: for argsdict in argsdict_list:
runcount += 1 runcount += 1
@ -91,7 +94,7 @@ def prerun(t_command_type='module', t_command_subtype=None):
if not trigger.sb["hyphen_arg"]: if not trigger.sb["hyphen_arg"]:
# check if anything prohibits the nick from running the command # check if anything prohibits the nick from running the command
if trigger_runstatus(bot, trigger): if trigger_runstatus(bot, trigger):
function(bot, trigger, *args, **kwargs) function(bot, trigger, botcom, *args, **kwargs)
else: else:
trigger_hyphen_arg_handler(bot, trigger) trigger_hyphen_arg_handler(bot, trigger)
botmessagelog.messagelog_exit(bot, argsdict_default["log_id"]) botmessagelog.messagelog_exit(bot, argsdict_default["log_id"])
@ -107,6 +110,8 @@ def prerun_query(t_command_type='module', t_command_subtype=None):
@functools.wraps(function) @functools.wraps(function)
def internal_prerun(bot, trigger, *args, **kwargs): def internal_prerun(bot, trigger, *args, **kwargs):
botcom = class_create('botcom')
if t_command_type == "nickname": if t_command_type == "nickname":
check_nick = spicemanip.main(trigger.args[1], 1).lower() check_nick = spicemanip.main(trigger.args[1], 1).lower()
if check_nick != str(bot.nick).lower(): if check_nick != str(bot.nick).lower():
@ -147,7 +152,7 @@ def prerun_query(t_command_type='module', t_command_subtype=None):
argsdict = trigger_argsdict_single(argsdict_default, trigger_args) argsdict = trigger_argsdict_single(argsdict_default, trigger_args)
# Run the function for all splits # Run the function for all splits
botmessagelog.messagelog_start(bot, trigger, argsdict_default["log_id"]) botmessagelog.messagelog_start(bot, trigger, argsdict_default["log_id"], argsdict_default["realcomtext"])
trigger.sb = copy.deepcopy(argsdict) trigger.sb = copy.deepcopy(argsdict)
@ -155,7 +160,7 @@ def prerun_query(t_command_type='module', t_command_subtype=None):
# check if anything prohibits the nick from running the command # check if anything prohibits the nick from running the command
if trigger_runstatus_query(bot, trigger): if trigger_runstatus_query(bot, trigger):
function(bot, trigger, *args, **kwargs) function(bot, trigger, botcom, *args, **kwargs)
botmessagelog.messagelog_exit(bot, argsdict_default["log_id"]) botmessagelog.messagelog_exit(bot, argsdict_default["log_id"])
return internal_prerun return internal_prerun
@ -231,37 +236,37 @@ def trigger_runstatus_query(bot, trigger):
# don't run commands that are disabled in channels # don't run commands that are disabled in channels
if not trigger.is_privmsg: if not trigger.is_privmsg:
channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender), "fully") channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender))
if "nickname_query" in list(channel_disabled_list.keys()): if "nickname_query" in list(channel_disabled_list.keys()):
return False return False
# don't run commands that are disabled for specific users # don't run commands that are disabled for specific users
nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick), "fully") nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick))
if "nickname_query" in list(nick_disabled_list.keys()): if "nickname_query" in list(nick_disabled_list.keys()):
return False return False
# don't run commands that are disabled in channels # don't run commands that are disabled in channels
if not trigger.is_privmsg: if not trigger.is_privmsg:
channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender), "fully") channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender))
if "nickname_query" in list(channel_disabled_list.keys()): if trigger.sb["realcomref"] in list(channel_disabled_list.keys()):
reason = channel_disabled_list["nickname_query"]["reason"] reason = channel_disabled_list[trigger.sb["realcomref"]]["reason"]
timestamp = channel_disabled_list["nickname_query"]["timestamp"] timestamp = channel_disabled_list[trigger.sb["realcomref"]]["timestamp"]
bywhom = channel_disabled_list["nickname_query"]["disabledby"] bywhom = channel_disabled_list[trigger.sb["realcomref"]]["disabledby"]
message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason) message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
return trigger_cant_run(bot, trigger, message) return trigger_cant_run(bot, trigger, message)
# don't run commands that are disabled for specific users # don't run commands that are disabled for specific users
nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick), "fully") nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick))
if "nickname_query" in list(nick_disabled_list.keys()): if trigger.sb["realcomref"] in list(nick_disabled_list.keys()):
bywhom = nick_disabled_list["nickname_query"]["disabledby"] bywhom = nick_disabled_list[trigger.sb["realcomref"]]["disabledby"]
if bywhom != trigger.nick: if botusers.ID(bywhom) != botusers.ID(trigger.nick):
reason = nick_disabled_list["nickname_query"]["reason"] reason = nick_disabled_list[trigger.sb["realcomref"]]["reason"]
timestamp = nick_disabled_list["nickname_query"]["timestamp"] timestamp = nick_disabled_list[trigger.sb["realcomref"]]["timestamp"]
message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason) message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
return trigger_cant_run(bot, trigger, message) return trigger_cant_run(bot, trigger, message)
else: else:
botcommands.unset_command_disabled(trigger.sb["realcomref"], trigger.nick, "fully") botcommands.unset_command_disabled(trigger.sb["realcomref"], trigger.nick)
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is now enabled for " + str(trigger.nick)) botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is now enabled for " + str(trigger.nick))
return True return True
@ -287,20 +292,20 @@ def trigger_runstatus(bot, trigger):
# check channel multirun blocks # check channel multirun blocks
if not trigger.is_privmsg: if not trigger.is_privmsg:
channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender), "multirun") channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender), "multirun")
if trigger.sb["realcom"] in list(channel_disabled_list.keys()): if trigger.sb["realcomref"] in list(channel_disabled_list.keys()):
reason = channel_disabled_list[trigger.sb["realcom"]]["reason"] reason = channel_disabled_list[trigger.sb["realcomref"]]["reason"]
timestamp = channel_disabled_list[trigger.sb["realcom"]]["timestamp"] timestamp = channel_disabled_list[trigger.sb["realcomref"]]["timestamp"]
bywhom = channel_disabled_list[trigger.sb["realcom"]]["disabledby"] bywhom = channel_disabled_list[trigger.sb["realcomref"]]["disabledby"]
message = "The " + str(trigger.sb["comtext"]) + " command multirun usage was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason) message = "The " + str(trigger.sb["comtext"]) + " command multirun usage was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
return trigger_cant_run(bot, trigger, message) return trigger_cant_run(bot, trigger, message)
# don't run commands that are disabled for specific users # don't run commands that are disabled for specific users
nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick), "multirun") nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick), "multirun")
if trigger.sb["realcom"] in list(nick_disabled_list.keys()): if trigger.sb["realcomref"] in list(nick_disabled_list.keys()):
bywhom = nick_disabled_list[trigger.sb["realcom"]]["disabledby"] bywhom = nick_disabled_list[trigger.sb["realcomref"]]["disabledby"]
if bywhom != trigger.nick: if botusers.ID(bywhom) != botusers.ID(trigger.nick):
reason = nick_disabled_list[trigger.sb["realcom"]]["reason"] reason = nick_disabled_list[trigger.sb["realcomref"]]["reason"]
timestamp = nick_disabled_list[trigger.sb["realcom"]]["timestamp"] timestamp = nick_disabled_list[trigger.sb["realcomref"]]["timestamp"]
message = "The " + str(trigger.sb["comtext"]) + " command was multirun unsage disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason) message = "The " + str(trigger.sb["comtext"]) + " command was multirun unsage disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
return trigger_cant_run(bot, trigger, message) return trigger_cant_run(bot, trigger, message)
else: else:
@ -309,26 +314,26 @@ def trigger_runstatus(bot, trigger):
# don't run commands that are disabled in channels # don't run commands that are disabled in channels
if not trigger.is_privmsg: if not trigger.is_privmsg:
channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender), "fully") channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender))
if trigger.sb["realcom"] in list(channel_disabled_list.keys()): if trigger.sb["realcomref"] in list(channel_disabled_list.keys()):
reason = channel_disabled_list[trigger.sb["realcom"]]["reason"] reason = channel_disabled_list[trigger.sb["realcomref"]]["reason"]
timestamp = channel_disabled_list[trigger.sb["realcom"]]["timestamp"] timestamp = channel_disabled_list[trigger.sb["realcomref"]]["timestamp"]
bywhom = channel_disabled_list[trigger.sb["realcom"]]["disabledby"] bywhom = channel_disabled_list[trigger.sb["realcomref"]]["disabledby"]
message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason) message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
return trigger_cant_run(bot, trigger, message) return trigger_cant_run(bot, trigger, message)
# don't run commands that are disabled for specific users # don't run commands that are disabled for specific users
nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick), "fully") nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick))
if trigger.sb["realcom"] in list(nick_disabled_list.keys()): if trigger.sb["realcomref"] in list(nick_disabled_list.keys()):
bywhom = nick_disabled_list[trigger.sb["realcom"]]["disabledby"] bywhom = nick_disabled_list[trigger.sb["realcomref"]]["disabledby"]
if bywhom != trigger.nick: if botusers.ID(bywhom) != botusers.ID(trigger.nick):
reason = nick_disabled_list[trigger.sb["realcom"]]["reason"] reason = nick_disabled_list[trigger.sb["realcomref"]]["reason"]
timestamp = nick_disabled_list[trigger.sb["realcom"]]["timestamp"] timestamp = nick_disabled_list[trigger.sb["realcomref"]]["timestamp"]
message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason) message = "The " + str(trigger.sb["comtext"]) + " command was disabled by " + bywhom + " for " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
return trigger_cant_run(bot, trigger, message) return trigger_cant_run(bot, trigger, message)
else: else:
botcommands.unset_command_disabled(trigger.sb["realcomref"], trigger.nick, "fully") botcommands.unset_command_disabled(trigger.sb["realcomref"], trigger.nick)
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is now enabled for " + str(trigger.nick)) botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is now enabled for " + str(trigger.nick))
return True return True
@ -394,6 +399,7 @@ def trigger_hyphen_arg_handler(bot, trigger):
else: else:
botmessagelog.messagelog_error(trigger.sb["log_id"], "Who/Where am I disabling " + str(trigger.sb["comtext"]) + " usage for?") botmessagelog.messagelog_error(trigger.sb["log_id"], "Who/Where am I disabling " + str(trigger.sb["comtext"]) + " usage for?")
return return
trigger.sb["args"] = spicemanip.main(trigger.sb["args"], "2+", "list")
if not botdb.check_nick_id(target) and not botchannels.check_channel_bot(target, True): if not botdb.check_nick_id(target) and not botchannels.check_channel_bot(target, True):
botmessagelog.messagelog_error(trigger.sb["log_id"], "I don't know who/what " + str(target) + " is.") botmessagelog.messagelog_error(trigger.sb["log_id"], "I don't know who/what " + str(target) + " is.")
@ -409,24 +415,24 @@ def trigger_hyphen_arg_handler(bot, trigger):
if trigger.sb["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]: if trigger.sb["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]:
if not botcommands.check_commands_disabled(trigger.sb["realcomref"], target, "fully"): if not botcommands.check_commands_disabled(trigger.sb["realcomref"], target):
botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is already enabled for " + str(target)) botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is already enabled for " + str(target))
return return
botcommands.unset_command_disabled(trigger.sb["realcomref"], target, "fully") botcommands.unset_command_disabled(trigger.sb["realcomref"], target)
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is now enabled for " + str(target)) botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is now enabled for " + str(target))
return return
else: else:
if botcommands.check_commands_disabled(trigger.sb["realcomref"], target, "fully"): if botcommands.check_commands_disabled(trigger.sb["realcomref"], target):
botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is already disabled for " + str(target)) botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is already disabled for " + str(target))
return return
trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given." trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given."
timestamp = str(datetime.datetime.utcnow()) timestamp = str(datetime.datetime.utcnow())
botcommands.set_command_disabled(trigger.sb["realcomref"], target, timestamp, trailingmessage, trigger.nick, "fully") botcommands.set_command_disabled(trigger.sb["realcomref"], target, timestamp, trailingmessage, trigger.nick)
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is now disabled for " + str(target)) botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is now disabled for " + str(target))
return return
@ -444,6 +450,7 @@ def trigger_hyphen_arg_handler(bot, trigger):
else: else:
botmessagelog.messagelog_error(trigger.sb["log_id"], "Who/Where am I disabling " + str(trigger.sb["comtext"]) + " multirun usage for?") botmessagelog.messagelog_error(trigger.sb["log_id"], "Who/Where am I disabling " + str(trigger.sb["comtext"]) + " multirun usage for?")
return return
trigger.sb["args"] = spicemanip.main(trigger.sb["args"], "2+", "list")
if not botdb.check_nick_id(target) and not botchannels.check_channel_bot(target, True): if not botdb.check_nick_id(target) and not botchannels.check_channel_bot(target, True):
botmessagelog.messagelog_error(trigger.sb["log_id"], "I don't know who/what " + str(target) + " is.") botmessagelog.messagelog_error(trigger.sb["log_id"], "I don't know who/what " + str(target) + " is.")

View File

@ -86,6 +86,41 @@ def command_permissions_check(bot, trigger, privslist):
return True return True
"""
Classes
"""
def class_create(classname):
compiletext = """
def __init__(self):
self.default = str(self.__class__.__name__)
def __repr__(self):
return repr(self.default)
def __str__(self):
return str(self.default)
def __iter__(self):
return str(self.default)
pass
"""
exec(compile("class class_" + str(classname) + ": " + compiletext, "", "exec"))
newclass = eval('class_'+classname+"()")
return newclass
def class_directory(inputclass):
# make sure input is a class
# if not isinstance(inputclass, class):
# return []
classdirlistfull, classdirlistclean = dir(inputclass), []
for classdiritem in classdirlistfull:
if not classdiritem.startswith("_"):
classdirlistclean.append(classdiritem)
return classdirlistclean
""" """
Time Time
""" """

View File

@ -236,13 +236,6 @@ class BotUsers():
def mode(self, bot, trigger): def mode(self, bot, trigger):
return return
def targetcheck(self, target):
return True
# idk whois
if not botdb.check_nick_id(target):
return
def nick_actual(self, nick, altlist=None): def nick_actual(self, nick, altlist=None):
nick_id = self.whois_ident(nick) nick_id = self.whois_ident(nick)
nick_actual = self.ID(nick_id) nick_actual = self.ID(nick_id)

View File

@ -11,7 +11,7 @@ import spicemanip
@SpiceBot.prerun('nickname') @SpiceBot.prerun('nickname')
@sopel.module.nickname_commands('ai') @sopel.module.nickname_commands('ai')
def ai_trigger(bot, trigger): def ai_trigger(bot, trigger, botcom):
availablecomsnum = SpiceBot.botai.dict['patterncounts'] availablecomsnum = SpiceBot.botai.dict['patterncounts']
availablecomsfiles = SpiceBot.botai.dict['filecounts'] availablecomsfiles = SpiceBot.botai.dict['filecounts']
displayval = "There are " + str(availablecomsnum) + " AI pattern matches available in " + str(availablecomsfiles) + " files." displayval = "There are " + str(availablecomsnum) + " AI pattern matches available in " + str(availablecomsfiles) + " files."
@ -209,7 +209,7 @@ def bot_command_rule_ai(bot, trigger):
# elif fulltrigger.lower().startswith(tuple(["have you seen"])): # elif fulltrigger.lower().startswith(tuple(["have you seen"])):
# posstarget = spicemanip.main(trigger_args, 4) or 0 # posstarget = spicemanip.main(trigger_args, 4) or 0
# message = seen_search(bot, botcom, posstarget) # message = seen_search(bot, trigger, posstarget)
# bot.osd(message) # bot.osd(message)
# return # return
# TODO # TODO

View File

@ -11,13 +11,13 @@ import sopel_modules.SpiceBot as SpiceBot
@SpiceBot.prerun('nickname') @SpiceBot.prerun('nickname')
@sopel.module.nickname_commands('owners', 'owner') @sopel.module.nickname_commands('owners', 'owner')
def bot_command_owners(bot, trigger): def bot_command_owners(bot, trigger, botcom):
bot_command_process(bot, trigger) bot_command_process(bot, trigger)
@SpiceBot.prerun('nickname') @SpiceBot.prerun('nickname')
@sopel.module.nickname_commands('admins', 'admin') @sopel.module.nickname_commands('admins', 'admin')
def bot_command_admins(bot, trigger): def bot_command_admins(bot, trigger, botcom):
bot_command_process(bot, trigger) bot_command_process(bot, trigger)

View File

@ -13,7 +13,7 @@ import sopel_modules.SpiceBot as SpiceBot
@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED]) @SpiceBot.events.check_ready([SpiceBot.events.BOT_LOADED])
@SpiceBot.prerun('nickname') @SpiceBot.prerun('nickname')
@sopel.module.nickname_commands('channels', 'channel') @sopel.module.nickname_commands('channels', 'channel')
def nickname_comand_channels(bot, trigger): def nickname_comand_channels(bot, trigger, botcom):
if not len(trigger.sb['args']): if not len(trigger.sb['args']):
commandused = 'list' commandused = 'list'
@ -49,7 +49,7 @@ def nickname_comand_channels(bot, trigger):
elif commandused == 'update': elif commandused == 'update':
if not trigger.admin: if not trigger.admin:
bot.osd("You do not have permission to update the channel listing.") SpiceBot.messagelog.messagelog_error("You do not have permission to update the channel listing.")
return return
SpiceBot.channels.bot_part_empty(bot) SpiceBot.channels.bot_part_empty(bot)
SpiceBot.channels.channel_list_request(bot) SpiceBot.channels.channel_list_request(bot)
@ -64,11 +64,11 @@ def nickname_comand_channels(bot, trigger):
elif commandused == 'topic': elif commandused == 'topic':
if not len(trigger.sb['args']): if not len(trigger.sb['args']):
bot.osd("Channel name input missing.") SpiceBot.messagelog.messagelog_error("Channel name input missing.")
return return
channel = spicemanip.main(trigger.sb['args'], 1) channel = spicemanip.main(trigger.sb['args'], 1)
if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())): if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())):
bot.osd("Channel name {} not valid.".format(channel)) SpiceBot.messagelog.messagelog_error("Channel name {} not valid.".format(channel))
return return
topic = SpiceBot.channels.dict['list'][channel.lower()]['topic'] topic = SpiceBot.channels.dict['list'][channel.lower()]['topic']
channel = SpiceBot.channels.dict['list'][channel.lower()]['name'] channel = SpiceBot.channels.dict['list'][channel.lower()]['name']
@ -78,17 +78,17 @@ def nickname_comand_channels(bot, trigger):
if commandused.upper() in ['OP', 'HOP', 'VOICE', 'OWNER', 'ADMIN']: if commandused.upper() in ['OP', 'HOP', 'VOICE', 'OWNER', 'ADMIN']:
if not len(trigger.sb['args']): if not len(trigger.sb['args']):
if trigger.is_privmsg: if trigger.is_privmsg:
bot.osd("Channel name required.") SpiceBot.messagelog.messagelog_error("Channel name required.")
return return
else: else:
channel = trigger.sender channel = trigger.sender
else: else:
channel = spicemanip.main(trigger.sb['args'], 1) channel = spicemanip.main(trigger.sb['args'], 1)
if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())): if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())):
bot.osd("Channel name {} not valid.".format(channel)) SpiceBot.messagelog.messagelog_error("Channel name {} not valid.".format(channel))
return return
if not SpiceBot.inlist(channel.lower(), list(bot.channels.keys())): if not SpiceBot.inlist(channel.lower(), list(bot.channels.keys())):
bot.osd("I need to be in {} to see nick privileges.".format(channel)) SpiceBot.messagelog.messagelog_error("I need to be in {} to see nick privileges.".format(channel))
return return
privlist = SpiceBot.channel_privs(bot, channel, commandused.upper()) privlist = SpiceBot.channel_privs(bot, channel, commandused.upper())
@ -105,10 +105,10 @@ def nickname_comand_channels(bot, trigger):
if commandused == 'users': if commandused == 'users':
channel = spicemanip.main(trigger.sb['args'], 1) channel = spicemanip.main(trigger.sb['args'], 1)
if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())): if not SpiceBot.inlist(channel.lower(), list(SpiceBot.channels.dict['list'].keys())):
bot.osd("Channel name {} not valid.".format(channel)) SpiceBot.messagelog.messagelog_error("Channel name {} not valid.".format(channel))
return return
if not SpiceBot.inlist(channel.lower(), list(bot.channels.keys())): if not SpiceBot.inlist(channel.lower(), list(bot.channels.keys())):
bot.osd("I need to be in {} to see user list.".format(channel)) SpiceBot.messagelog.messagelog_error("I need to be in {} to see user list.".format(channel))
return return
dispmsg = [] dispmsg = []
if not len(list(bot.channels[channel].privileges.keys())): if not len(list(bot.channels[channel].privileges.keys())):

View File

@ -17,7 +17,7 @@ import sopel_modules.SpiceBot as SpiceBot
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS]) @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS])
@SpiceBot.prerun('nickname') @SpiceBot.prerun('nickname')
@sopel.module.nickname_commands('commands', 'command') @sopel.module.nickname_commands('commands', 'command')
def nickname_comand_commands(bot, trigger): def nickname_comand_commands(bot, trigger, botcom):
if not len(trigger.sb['args']): if not len(trigger.sb['args']):
commandused = 'list' commandused = 'list'

View File

@ -14,14 +14,14 @@ import sopel_modules.SpiceBot as SpiceBot
@SpiceBot.prerun('nickname') @SpiceBot.prerun('nickname')
@sopel.module.nickname_commands('query') @sopel.module.nickname_commands('query')
def query_trigger(bot, trigger): def query_trigger(bot, trigger, botcom):
bot.osd("I have been programmed to help find new commands by using `?`.") bot.osd("I have been programmed to help find new commands by using `?`.")
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS]) @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS])
@SpiceBot.prerun_query('nickname', 'nickname') @SpiceBot.prerun_query('nickname', 'nickname')
@sopel.module.nickname_commands('(.*)') @sopel.module.nickname_commands('(.*)')
def query_detection_nick(bot, trigger): def query_detection_nick(bot, trigger, botcom):
# command issued, check if valid # command issued, check if valid
if not trigger.sb['com'] or not len(trigger.sb['com']): if not trigger.sb['com'] or not len(trigger.sb['com']):
@ -87,7 +87,7 @@ def query_detection_nick(bot, trigger):
@SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS]) @SpiceBot.events.check_ready([SpiceBot.events.BOT_COMMANDS])
@SpiceBot.prerun_query('module', 'module') @SpiceBot.prerun_query('module', 'module')
@sopel.module.rule('^\?(.*)') @sopel.module.rule('^\?(.*)')
def query_detection(bot, trigger): def query_detection(bot, trigger, botcom):
# command issued, check if valid # command issued, check if valid
if not trigger.sb['com'] or not len(trigger.sb['com']): if not trigger.sb['com'] or not len(trigger.sb['com']):

View File

@ -17,7 +17,7 @@ from random import randint
@SpiceBot.prerun('module', 'dictcom') @SpiceBot.prerun('module', 'dictcom')
@sopel.module.commands('(.*)') @sopel.module.commands('(.*)')
def command_dictcom(bot, trigger): def command_dictcom(bot, trigger, botcom):
if trigger.sb['com'] not in list(SpiceBot.commands.dict['commands']["dictcom"].keys()): if trigger.sb['com'] not in list(SpiceBot.commands.dict['commands']["dictcom"].keys()):
return return
@ -145,7 +145,7 @@ def bot_dictcom_process(bot, trigger):
if trigger.sb["dict"][trigger.sb["responsekey"]]["type"] in ['simple', 'fillintheblank', "target", 'targetplusreason', 'sayings', "readfromfile", "readfromurl", "ascii_art", "translate", "responses"]: if trigger.sb["dict"][trigger.sb["responsekey"]]["type"] in ['simple', 'fillintheblank', "target", 'targetplusreason', 'sayings', "readfromfile", "readfromurl", "ascii_art", "translate", "responses"]:
return bot_dictcom_responses(bot, trigger) return bot_dictcom_responses(bot, trigger)
else: else:
command_function_run = str('bot_dictcom_' + trigger.sb["dict"][trigger.sb["responsekey"]]["type"] + '(bot, botcom)') command_function_run = str('bot_dictcom_' + trigger.sb["dict"][trigger.sb["responsekey"]]["type"] + '(bot, trigger)')
eval(command_function_run) eval(command_function_run)
@ -404,5 +404,5 @@ def bot_dictcom_feeds(bot, trigger):
""" """
def bot_dictcom_search(bot, botcom): def bot_dictcom_search(bot, trigger):
bot.say("testing done") bot.say("testing done")

View File

@ -13,10 +13,10 @@ import spicemanip
@SpiceBot.prerun('module') @SpiceBot.prerun('module')
@sopel.module.commands('gif') @sopel.module.commands('gif')
def gif_trigger(bot, trigger): def gif_trigger(bot, trigger, botcom):
if not len(trigger.sb['args']): if not len(trigger.sb['args']):
return bot.osd("Please present a query to search.") return SpiceBot.messagelog.messagelog_error("Please present a query to search.")
query = spicemanip.main(trigger.sb['args'], 0) query = spicemanip.main(trigger.sb['args'], 0)
searchapis = list(SpiceBot.gif.valid_api.keys()) searchapis = list(SpiceBot.gif.valid_api.keys())
@ -25,20 +25,20 @@ def gif_trigger(bot, trigger):
gifdict = SpiceBot.gif.get_gif(searchdict) gifdict = SpiceBot.gif.get_gif(searchdict)
if gifdict["error"]: if gifdict["error"]:
bot.osd(gifdict["error"]) SpiceBot.messagelog.messagelog_error(gifdict["error"])
else: else:
bot.osd(str(gifdict['gifapi'].title() + " Result (" + str(query) + " #" + str(gifdict["returnnum"]) + "): " + str(gifdict["returnurl"]))) bot.osd(str(gifdict['gifapi'].title() + " Result (" + str(query) + " #" + str(gifdict["returnnum"]) + "): " + str(gifdict["returnurl"])))
@SpiceBot.prerun('module', "gif_prefix") @SpiceBot.prerun('module', "gif_prefix")
@sopel.module.commands('(.*)') @sopel.module.commands('(.*)')
def gifapi_triggers(bot, trigger): def gifapi_triggers(bot, trigger, botcom):
if trigger.sb['com'] not in list(SpiceBot.gif.valid_api.keys()): if trigger.sb['com'] not in list(SpiceBot.gif.valid_api.keys()):
return return
if not len(trigger.sb['args']): if not len(trigger.sb['args']):
return bot.osd("Please present a query to search.") return SpiceBot.messagelog.messagelog_error("Please present a query to search.")
query = spicemanip.main(trigger.sb['args'], 0) query = spicemanip.main(trigger.sb['args'], 0)
searchdict = {"query": query, "gifsearch": trigger.sb['com']} searchdict = {"query": query, "gifsearch": trigger.sb['com']}
@ -46,6 +46,6 @@ def gifapi_triggers(bot, trigger):
gifdict = SpiceBot.gif.get_gif(searchdict) gifdict = SpiceBot.gif.get_gif(searchdict)
if gifdict["error"]: if gifdict["error"]:
bot.osd(gifdict["error"]) SpiceBot.messagelog.messagelog_error(gifdict["error"])
else: else:
bot.osd(str(gifdict['gifapi'].title() + " Result (" + str(query) + " #" + str(gifdict["returnnum"]) + "): " + str(gifdict["returnurl"]))) bot.osd(str(gifdict['gifapi'].title() + " Result (" + str(query) + " #" + str(gifdict["returnnum"]) + "): " + str(gifdict["returnurl"])))

View File

@ -15,10 +15,10 @@ import sopel_modules.SpiceBot as SpiceBot
@SpiceBot.events.check_ready([SpiceBot.events.BOT_LOGS]) @SpiceBot.events.check_ready([SpiceBot.events.BOT_LOGS])
@SpiceBot.prerun('nickname') @SpiceBot.prerun('nickname')
@sopel.module.nickname_commands('logs', 'debug') @sopel.module.nickname_commands('logs', 'debug')
def bot_command_logs(bot, trigger): def bot_command_logs(bot, trigger, botcom):
if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
bot.osd("I was unable to process this Bot Nick command due to privilege issues.") SpiceBot.messagelog.messagelog_error("I was unable to process this Bot Nick command due to privilege issues.")
return return
logtype = spicemanip.main(trigger.sb['args'], 1) or None logtype = spicemanip.main(trigger.sb['args'], 1) or None
@ -29,9 +29,9 @@ def bot_command_logs(bot, trigger):
if not SpiceBot.inlist(logtype, list(SpiceBot.logs.dict["list"].keys())): if not SpiceBot.inlist(logtype, list(SpiceBot.logs.dict["list"].keys())):
closestmatches = SpiceBot.similar_list(logtype, list(SpiceBot.logs.dict["list"].keys()), 10, 'reverse') closestmatches = SpiceBot.similar_list(logtype, list(SpiceBot.logs.dict["list"].keys()), 10, 'reverse')
if not len(closestmatches): if not len(closestmatches):
bot.osd("No valid logs match " + str(logtype) + ".", trigger.nick, 'notice') SpiceBot.messagelog.messagelog_error("No valid logs match " + str(logtype) + ".", trigger.nick, 'notice')
else: else:
bot.osd("The following commands may match " + str(logtype) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice') SpiceBot.messagelog.messagelog_error("The following commands may match " + str(logtype) + ": " + spicemanip.main(closestmatches, 'andlist') + ".", trigger.nick, 'notice')
return return
@ -40,7 +40,7 @@ def bot_command_logs(bot, trigger):
logindex = SpiceBot.logs.get_logs(logtype) logindex = SpiceBot.logs.get_logs(logtype)
if not len(logindex): if not len(logindex):
bot.osd("No logs found for " + str(logtype) + ".") SpiceBot.messagelog.messagelog_error("No logs found for " + str(logtype) + ".")
return return
bot.osd("Is Examining " + str(logtype) + " log(s).") bot.osd("Is Examining " + str(logtype) + " log(s).")

View File

@ -11,40 +11,40 @@ import sopel_modules.SpiceBot as SpiceBot
@SpiceBot.prerun('nickname') @SpiceBot.prerun('nickname')
@sopel.module.nickname_commands('action') @sopel.module.nickname_commands('action')
def bot_command_action(bot, trigger): def bot_command_action(bot, trigger, botcom):
bot_command_process(bot, trigger) bot_command_process(bot, trigger)
@SpiceBot.prerun('nickname') @SpiceBot.prerun('nickname')
@sopel.module.nickname_commands('notice') @sopel.module.nickname_commands('notice')
def bot_command_notice(bot, trigger): def bot_command_notice(bot, trigger, botcom):
bot_command_process(bot, trigger) bot_command_process(bot, trigger)
@SpiceBot.prerun('nickname') @SpiceBot.prerun('nickname')
@sopel.module.nickname_commands('privmsg', 'say', 'msg') @sopel.module.nickname_commands('privmsg', 'say', 'msg')
def bot_command_privmsg(bot, trigger): def bot_command_privmsg(bot, trigger, botcom):
bot_command_process(bot, trigger) bot_command_process(bot, trigger)
def bot_command_process(bot, trigger): def bot_command_process(bot, trigger):
if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner']): if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner']):
bot.osd("I was unable to process this Bot Nick command due to privilege issues.") SpiceBot.messagelog.messagelog_error("I was unable to process this Bot Nick command due to privilege issues.")
return return
if trigger.sb['com'] in ['say', 'msg']: if trigger.sb['com'] in ['say', 'msg']:
trigger.sb['com'] = 'privmsg' trigger.sb['com'] = 'privmsg'
if not len(trigger.sb['args']): if not len(trigger.sb['args']):
bot.osd("You must specify a channel or nick.") SpiceBot.messagelog.messagelog_error("You must specify a channel or nick.")
return return
target = spicemanip.main(trigger.sb['args'], 1) target = spicemanip.main(trigger.sb['args'], 1)
if (target not in ['allchans', 'allnicks'] if (target not in ['allchans', 'allnicks']
and not SpiceBot.inlist(target.lower(), list(SpiceBot.channels.dict['list'].keys())) and not SpiceBot.inlist(target.lower(), list(SpiceBot.channels.dict['list'].keys()))
and not SpiceBot.inlist(target.lower(), bot.users)): and not SpiceBot.inlist(target.lower(), bot.users)):
bot.osd("Channel/nick name {} not valid.".format(target)) SpiceBot.messagelog.messagelog_error("Channel/nick name {} not valid.".format(target))
return return
trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list')
@ -58,7 +58,7 @@ def bot_command_process(bot, trigger):
botmessage = spicemanip.main(trigger.sb['args'], 0) botmessage = spicemanip.main(trigger.sb['args'], 0)
if not botmessage: if not botmessage:
bot.osd("You must specify a message to send.") SpiceBot.messagelog.messagelog_error("You must specify a message to send.")
return return
bot.osd(botmessage, targetsendlist, trigger.sb['com'].upper()) bot.osd(botmessage, targetsendlist, trigger.sb['com'].upper())

View File

@ -11,10 +11,10 @@ import sopel_modules.SpiceBot as SpiceBot
@SpiceBot.prerun('nickname') @SpiceBot.prerun('nickname')
@sopel.module.nickname_commands('update') @sopel.module.nickname_commands('update')
def nickname_comand_update(bot, trigger): def nickname_comand_update(bot, trigger, botcom):
if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']): if not SpiceBot.command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
bot.osd("I was unable to process this Bot Nick command due to privilege issues.") SpiceBot.messagelog.messagelog_error("I was unable to process this Bot Nick command due to privilege issues.")
return return
if not len(trigger.sb['args']): if not len(trigger.sb['args']):
@ -23,7 +23,7 @@ def nickname_comand_update(bot, trigger):
commandused = spicemanip.main(trigger.sb['args'], 1).lower() commandused = spicemanip.main(trigger.sb['args'], 1).lower()
if commandused not in ['deps', 'nodeps']: if commandused not in ['deps', 'nodeps']:
bot.osd("Please specify deps or nodeps") SpiceBot.messagelog.messagelog_error("Please specify deps or nodeps")
return return
trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list') trigger.sb['args'] = spicemanip.main(trigger.sb['args'], '2+', 'list')
@ -42,10 +42,10 @@ def nickname_comand_update(bot, trigger):
@sopel.module.nickname_commands('restart') @sopel.module.nickname_commands('restart')
def nickname_comand_restart(bot, trigger): def nickname_comand_restart(bot, trigger, botcom):
if not trigger.admin: if not trigger.admin:
bot.osd("You are not authorized to perform this function.") SpiceBot.messagelog.messagelog_error("You are not authorized to perform this function.")
quitmessage = "Received command from " + trigger.nick + " to restart. Be Back Soon!" quitmessage = "Received command from " + trigger.nick + " to restart. Be Back Soon!"
SpiceBot.logs.log('SpiceBot_Restart', quitmessage) SpiceBot.logs.log('SpiceBot_Restart', quitmessage)

View File

@ -12,63 +12,63 @@ import sopel_modules.SpiceBot as SpiceBot
@SpiceBot.prerun('module') @SpiceBot.prerun('module')
@sopel.module.commands('search', 'find', 'google', 'lookup') @sopel.module.commands('search', 'find', 'google', 'lookup')
def search_main(bot, trigger): def search_main(bot, trigger, botcom):
searchterm = spicemanip.main(trigger.sb['args'], 0) or None searchterm = spicemanip.main(trigger.sb['args'], 0) or None
if not searchterm: if not searchterm:
bot.osd("Not sure what you want me to look for.") SpiceBot.messagelog.messagelog_error("Not sure what you want me to look for.")
return return
searchreturn = SpiceBot.google.search(searchterm) searchreturn = SpiceBot.google.search(searchterm)
if not searchreturn: if not searchreturn:
bot.osd('I cannot find anything about that') SpiceBot.messagelog.messagelog_error('I cannot find anything about that')
else: else:
bot.osd(["[Information search for '" + str(searchterm) + "']", str(searchreturn)]) bot.osd(["[Information search for '" + str(searchterm) + "']", str(searchreturn)])
@SpiceBot.prerun('module') @SpiceBot.prerun('module')
@sopel.module.commands("where", "whereis") @sopel.module.commands("where", "whereis")
def search_where(bot, trigger): def search_where(bot, trigger, botcom):
searchterm = spicemanip.main(trigger.sb['args'], 0) or None searchterm = spicemanip.main(trigger.sb['args'], 0) or None
if not searchterm: if not searchterm:
bot.osd("Not sure what you want me to look for.") SpiceBot.messagelog.messagelog_error("Not sure what you want me to look for.")
return return
searchreturn = SpiceBot.google.search(searchterm, 'maps') searchreturn = SpiceBot.google.search(searchterm, 'maps')
if not searchreturn: if not searchreturn:
bot.osd('I cannot find anything about that') SpiceBot.messagelog.messagelog_error('I cannot find anything about that')
else: else:
bot.osd(["[Location search for " + str(searchterm) + "]", str(searchreturn)]) bot.osd(["[Location search for " + str(searchterm) + "]", str(searchreturn)])
@SpiceBot.prerun('module') @SpiceBot.prerun('module')
@sopel.module.commands("what", "whatis") @sopel.module.commands("what", "whatis")
def search_what(bot, trigger): def search_what(bot, trigger, botcom):
searchterm = spicemanip.main(trigger.sb['args'], 0) or None searchterm = spicemanip.main(trigger.sb['args'], 0) or None
if not searchterm: if not searchterm:
bot.osd("Not sure what you want me to look for.") SpiceBot.messagelog.messagelog_error("Not sure what you want me to look for.")
return return
searchreturn = SpiceBot.google.search(searchterm) searchreturn = SpiceBot.google.search(searchterm)
if not searchreturn: if not searchreturn:
bot.osd('I cannot find anything about that') SpiceBot.messagelog.messagelog_error('I cannot find anything about that')
else: else:
bot.osd(["[Information search for '" + str(searchterm) + "']", str(searchreturn)]) bot.osd(["[Information search for '" + str(searchterm) + "']", str(searchreturn)])
@SpiceBot.prerun('module') @SpiceBot.prerun('module')
@sopel.module.commands("youtube", "video") @sopel.module.commands("youtube", "video")
def search_video(bot, trigger): def search_video(bot, trigger, botcom):
searchterm = spicemanip.main(trigger.sb['args'], 0) or None searchterm = spicemanip.main(trigger.sb['args'], 0) or None
if not searchterm: if not searchterm:
bot.osd("Not sure what you want me to look for.") SpiceBot.messagelog.messagelog_error("Not sure what you want me to look for.")
return return
searchreturn = SpiceBot.google.search(searchterm, 'youtube') searchreturn = SpiceBot.google.search(searchterm, 'youtube')
if not searchreturn: if not searchreturn:
bot.osd('I cannot find anything about that') SpiceBot.messagelog.messagelog_error('I cannot find anything about that')
else: else:
bot.osd(["[Youtube search for '" + str(searchterm) + "']", str(searchreturn)]) bot.osd(["[Youtube search for '" + str(searchterm) + "']", str(searchreturn)])

View File

@ -11,7 +11,7 @@ import sopel_modules.SpiceBot as SpiceBot
@SpiceBot.prerun('module') @SpiceBot.prerun('module')
@sopel.module.commands('sherlock', 'username') @sopel.module.commands('sherlock', 'username')
def bot_command_sherlock(bot, trigger): def bot_command_sherlock(bot, trigger, botcom):
netlist = list(SpiceBot.sherlock.dict.keys()) netlist = list(SpiceBot.sherlock.dict.keys())

View File

@ -11,6 +11,6 @@ import sopel_modules.SpiceBot as SpiceBot
@SpiceBot.prerun('nickname') @SpiceBot.prerun('nickname')
@sopel.module.nickname_commands('uptime') @sopel.module.nickname_commands('uptime')
def bot_command_uptime(bot, trigger): def bot_command_uptime(bot, trigger, botcom):
timesince = str(SpiceBot.humanized_time(time.time() - SpiceBot.events.BOT_UPTIME)) + " ago." timesince = str(SpiceBot.humanized_time(time.time() - SpiceBot.events.BOT_UPTIME)) + " ago."
bot.osd("I have been running since " + timesince) bot.osd("I have been running since " + timesince)