Merge pull request #72 from deathbybandaid/development

Development
This commit is contained in:
Deathbybandaid 2019-06-26 15:18:05 -04:00 committed by GitHub
commit fe5a36933f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 470 additions and 62 deletions

View File

@ -29,6 +29,7 @@ class BotChannels():
self.lock = threading.Lock()
self.channel_lock = False
self.channels = []
self.dict = {
"list": {},
"InitialProcess": False
@ -46,7 +47,7 @@ class BotChannels():
if channel.lower() not in list(self.dict["list"].keys()):
raise Exception('Channel ' + str(channel.lower()) + " does not seem to be on this server")
if 'users' not in list(self.dict["list"][channel.lower()].keys()):
if 'users' not in list(self.dict["list"][channel.lower()].keys()) or not self.check_channel_bot(channel):
raise Exception('Channel ' + str(channel.lower()) + " does not seem to be a channel the bot is in")
nick_ids = self.dict["list"][channel.lower()]['users']
@ -102,6 +103,8 @@ class BotChannels():
self.lock.acquire()
del self.dict['list'][channel.lower()]
self.lock.release()
if channel.lower() in self.channels:
self.channels.remove(channel.lower())
def join_all_channels(self, bot):
if botconfig.SpiceBot_Channels.joinall:
@ -112,6 +115,10 @@ class BotChannels():
if channel not in list(bot.channels.keys()) and botconfig.SpiceBot_Channels.operadmin:
bot.write(('SAJOIN', bot.nick, self.dict['list'][channel]['name']))
if channel in list(bot.channels.keys()):
if channel.lower() not in self.channels:
self.channels.append(channel.lower())
def chanadmin_all_channels(self, bot):
# Chan ADMIN +a
for channel in list(bot.channels.keys()):
@ -123,6 +130,10 @@ class BotChannels():
else:
bot.part(channel)
if channel not in list(bot.channels.keys()):
if channel.lower() in self.channels:
self.channels.remove(channel.lower())
def whois_ident(self, nick):
nick = Identifier(nick)
nick_id = botdb.db.get_nick_id(nick, create=True)
@ -138,6 +149,8 @@ class BotChannels():
self.dict['list'][channel.lower()]['users'] = []
if nick_id not in self.dict['list'][channel.lower()]['users']:
self.dict['list'][channel.lower()]['users'].append(int(nick_id))
if channel.lower() not in self.channels:
self.channels.append(channel.lower())
def remove_from_channel(self, channel, nick, nick_id=None):
channel = str(channel)
@ -157,6 +170,8 @@ class BotChannels():
if 'users' not in self.dict['list'][channel.lower()]:
self.dict['list'][channel.lower()]['users'] = []
self.dict['list'][channel.lower()]['users'] = []
if channel.lower() in self.channels:
self.channels.remove(channel.lower())
def channel_scan(self, bot):
for channel in list(bot.channels.keys()):
@ -221,5 +236,13 @@ class BotChannels():
def mode(self, bot, trigger):
return
def check_channel_bot(self, channel, allchan=False):
if str(channel).lower() in self.channels:
return True
elif allchan and str(channel).lower() in list(self.dict['list'].keys()):
return True
else:
return False
channels = BotChannels()

View File

@ -11,6 +11,7 @@ from sopel.config.types import StaticSection, ValidatedAttribute
import os
import threading
import copy
import spicemanip
import sopel_modules
@ -19,6 +20,7 @@ from .Logs import logs
from .Config import config as botconfig
from .Database import db as botdb
from .Read import read as botread
from .Channels import channels as botchannels
class SpiceBot_Commands_MainSection(StaticSection):
@ -38,7 +40,7 @@ class BotCommands():
'nickname': {},
'rule': {}
},
'disabled': {}
'disabled': {},
}
self.module_files_parse()
self.nickrules()
@ -67,16 +69,13 @@ class BotCommands():
return commandstype
return None
def get_commands_disabled(self, channel):
if not len(list(self.dict['disabled'])):
self.dict['disabled'] = botdb.get_channel_value(channel, 'commands_disabled') or {}
return self.dict['disabled']
def check_commands_disabled(self, command, channel):
if command in list(self.get_commands_disabled(channel).keys()):
return True
else:
return False
def get_command_dict(self, command, trigger_command_type=None):
if not trigger_command_type:
trigger_command_type = self.find_command_type(command)
if not trigger_command_type:
return {}
command_dict = copy.deepcopy(self.dict['commands'][trigger_command_type][command])
return command_dict
def get_realcom(self, command, trigger_command_type):
realcom = command
@ -92,18 +91,74 @@ class BotCommands():
return realcom
def set_command_disabled(self, command, channel, timestamp, reason, bywhom):
if not len(list(self.dict['disabled'])):
self.dict['disabled'] = botdb.get_channel_value(channel, 'commands_disabled') or {}
self.dict['disabled'][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom}
botdb.set_channel_value(channel, 'commands_disabled', self.dict['disabled'])
def get_commands_disabled(self, target, disabletype="fully"):
disabletype = str(disabletype)
if disabletype not in list(self.dict['disabled'].keys()):
self.dict['disabled'][disabletype] = {
"users": {},
"channels": {}
}
if botdb.check_nick_id(target):
if not len(list(self.dict['disabled'][disabletype]["users"])):
self.dict['disabled'][disabletype]["users"] = botdb.get_nick_value(target, 'commands_' + disabletype + 'disabled') or {}
return self.dict['disabled'][disabletype]["users"]
elif botchannels.check_channel_bot(target, True):
if not len(list(self.dict['disabled'][disabletype]["channels"])):
self.dict['disabled'][disabletype]["channels"] = botdb.get_channel_value(target, 'commands_disabled') or {}
return self.dict['disabled'][disabletype]["channels"]
else:
raise Exception(str(target.lower()) + " appears to not be a valid user/channel")
def unset_command_disabled(self, command, channel):
if not len(list(self.dict['disabled'])):
self.dict['disabled'] = botdb.get_channel_value(channel, 'commands_disabled') or {}
if command in list(self.dict['disabled'].keys()):
del self.dict['disabled'][command]
botdb.set_channel_value(channel, 'commands_disabled', self.dict['disabled'])
def check_commands_disabled(self, command, target, disabletype="fully"):
if disabletype not in list(self.dict['disabled'].keys()):
self.dict['disabled'][disabletype] = {
"users": {},
"channels": {}
}
if command in list(self.get_commands_disabled(target, disabletype).keys()):
return True
else:
return False
def set_command_disabled(self, command, target, timestamp, reason, bywhom, disabletype="fully"):
if disabletype not in list(self.dict['disabled'].keys()):
self.dict['disabled'][disabletype] = {
"users": {},
"channels": {}
}
if botdb.check_nick_id(target):
if not len(list(self.dict['disabled'][disabletype]["users"])):
self.dict['disabled'][disabletype]["users"] = botdb.get_nick_value(target, 'commands_disabled') or {}
self.dict['disabled'][disabletype]["users"][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom}
botdb.set_nick_value(target, 'commands_disabled', self.dict['disabled'][disabletype]["users"])
elif botchannels.check_channel_bot(target, True):
if not len(list(self.dict['disabled'][disabletype]["channels"])):
self.dict['disabled'][disabletype]["channels"] = botdb.get_channel_value(target, 'commands_disabled') or {}
self.dict['disabled'][disabletype]["channels"][command] = {"reason": reason, "timestamp": timestamp, "disabledby": bywhom}
botdb.set_channel_value(target, 'commands_disabled', self.dict['disabled'][disabletype]["channels"])
else:
raise Exception(str(target.lower()) + " appears to not be a valid user/channel")
def unset_command_disabled(self, command, target, disabletype="fully"):
if disabletype not in list(self.dict['disabled'].keys()):
self.dict['disabled'][disabletype] = {
"users": {},
"channels": {}
}
if botdb.check_nick_id(target):
if not len(list(self.dict['disabled'][disabletype]["users"])):
self.dict['disabled'][disabletype]["users"] = botdb.get_nick_value(target, 'commands_disabled') or {}
if command in list(self.dict['disabled'][disabletype]["users"].keys()):
del self.dict['disabled'][disabletype]["users"][command]
botdb.set_nick_value(target, 'commands_disabled', self.dict['disabled'][disabletype]["users"])
elif botchannels.check_channel_bot(target, True):
if not len(list(self.dict['disabled'][disabletype]["channels"])):
self.dict['disabled'][disabletype]["channels"] = botdb.get_channel_value(target, 'commands_disabled') or {}
if command in list(self.dict['disabled'][disabletype]["channels"].keys()):
del self.dict['disabled'][disabletype]["channels"][command]
botdb.set_channel_value(target, 'commands_disabled', self.dict['disabled'][disabletype]["channels"])
else:
raise Exception(str(target.lower()) + " appears to not be a valid user/channel")
def register(self, command_dict):

View File

@ -0,0 +1,175 @@
# coding=utf8
from __future__ import unicode_literals, absolute_import, division, print_function
"""
This is the SpiceBot Message Log system.
"""
import uuid
from .Config import config as botconfig
class MessageLog():
def __init__(self):
self.dict = {}
self.message_display = dict()
self.used_ids = [0]
self.used_error_ids = [0]
self.error_message_dict = {
"command_inchan_only": "$command must be run in channel.",
"admin_switch_unauth": "The admin switch (-a) is for use by authorized nicks ONLY.",
}
def messagelog_assign(self):
unique_id = 0
while unique_id in self.used_ids:
unique_id = uuid.uuid4()
self.used_ids.append(unique_id)
return unique_id
def messagelog_error_get(self, errormsg):
for error_id in list(self.error_message_dict.keys()):
if self.error_message_dict[error_id] == errormsg:
return error_id
unique_id = 0
while unique_id in self.used_error_ids:
unique_id = uuid.uuid4()
self.used_error_ids.append(unique_id)
self.error_message_dict[unique_id] = errormsg
return unique_id
def messagelog_start(self, bot, trigger, log_id):
if not trigger.is_privmsg:
channelname = trigger.sender
else:
channelname = None
self.message_display[log_id] = {
"trigger": {
"nick": trigger.nick,
"sender": channelname,
},
"bot": {
"nick": bot.nick
},
"messages": [],
}
def messagelog_error(self, log_id, error_id):
newloglist = []
error_exists_prior = False
if error_id not in self.error_message_dict:
error_id = self.messagelog_error_get(error_id)
for existing_messagedict in self.message_display[log_id]["messages"]:
if existing_messagedict["type"] == "error":
if existing_messagedict["error_id"] == error_id:
error_exists_prior = True
existing_messagedict["count"] += 1
newloglist.append(existing_messagedict)
if not error_exists_prior:
newmessagedict = {"type": "error", "error_id": error_id, "count": 1}
newloglist.append(newmessagedict)
self.message_display[log_id]["messages"] = newloglist
def messagelog_error_admins(self, bot, log_id, message):
recipients = list(botconfig.admins)
bot.osd(["Attention Bot Admin: ", message], recipients, 'notice')
# TODO
return
def messagelog(self, log_id, message, recipients=None):
if not recipients:
if self.message_display[log_id]["trigger"]["sender"]:
recipients = [self.message_display[log_id]["trigger"]["sender"]]
else:
recipients = [self.message_display[log_id]["trigger"]["nick"]]
if not isinstance(recipients, list):
recipients == [recipients]
messagedict = {"type": "normal", "message": message, "recipients": recipients}
self.message_display[log_id]["messages"].append(messagedict)
def messagelog_exit(self, bot, log_id):
current_messages = []
current_errors = []
for messagedict in self.message_display[log_id]["messages"]:
if messagedict["type"] == "error":
if messagedict["error_id"] not in self.error_message_dict.keys():
message = "Error missing for ID '" + str(messagedict["error_id"]) + "'"
else:
message = self.error_message_dict[messagedict["error_id"]]
message += " (" + str(messagedict["count"]) + ")"
message = self.messagelog_fillin(message, log_id)
current_errors.append(message)
else:
if len(current_errors):
currenterrordict = {"type": "error", "message": current_errors}
current_messages.append(currenterrordict)
current_errors = []
message = messagedict["message"]
current_messages.append(messagedict)
if len(current_errors):
currenterrordict = {"type": "error", "message": current_errors}
current_messages.append(currenterrordict)
current_errors = []
for messagedict in current_messages:
if messagedict["type"] == 'error':
bot.osd(messagedict['message'], self.message_display[log_id]["trigger"]["nick"], 'notice')
elif len(messagedict["recipients"]) > 1:
bot.osd(messagedict['message'], messagedict["recipients"], 'notice')
elif len(messagedict["recipients"]) == 1:
if messagedict["recipients"][0] == self.message_display[log_id]["trigger"]["nick"]:
bot.osd(messagedict['message'], self.message_display[log_id]["trigger"]["nick"], 'notice')
else:
bot.osd(messagedict['message'], messagedict["recipients"], 'say')
else:
bot.osd(messagedict['message'], messagedict["recipients"], 'say')
self.messagelog_kill(log_id)
def messagelog_fillin(self, message, log_id):
for botval in ["nick"]:
fullbotval = str("$bot." + botval)
fullbotvaleval = self.message_display[log_id]["bot"][botval]
if fullbotval in message:
message = str(message.replace(fullbotval, fullbotvaleval))
for triggerval in ["nick", "sender"]:
fulltriggerval = str("$trigger." + triggerval)
fulltriggervaleval = self.message_display[log_id]["trigger"][triggerval]
if fulltriggerval in message:
if fulltriggervaleval:
message = str(message.replace(fulltriggerval, fulltriggervaleval))
else:
if triggerval == "sender":
message = str(message.replace("$trigger.sender", 'privmsg'))
else:
message = str(message.replace(fulltriggerval, str(fulltriggervaleval)))
return message
def messagelog_kill(self, log_id):
if log_id in self.message_display:
del self.message_display[log_id]
messagelog = MessageLog()

View File

@ -15,6 +15,8 @@ import spicemanip
from .Tools import command_permissions_check
from .Commands import commands as botcommands
from .Database import db as botdb
from .Channels import channels as botchannels
from .MessageLog import messagelog as botmessagelog
def prerun(t_command_type='module', t_command_subtype=None):
@ -42,8 +44,19 @@ def prerun(t_command_type='module', t_command_subtype=None):
argsdict_default["type"] = trigger_command_type
argsdict_default["com"] = trigger_command
realcom = botcommands.get_realcom(argsdict_default["com"], trigger_command_type)
argsdict_default["realcom"] = realcom
# messagelog ID
argsdict_default["log_id"] = botmessagelog.messagelog_assign()
argsdict_default["realcom"] = botcommands.get_realcom(argsdict_default["com"], trigger_command_type)
if argsdict_default["type"] == 'nickname':
argsdict_default["comtext"] = bot.nick + " " + argsdict_default["com"]
argsdict_default["realcomtext"] = bot.nick + " " + argsdict_default["realcom"]
else:
argsdict_default["comtext"] = argsdict_default["com"]
argsdict_default["realcomtext"] = argsdict_default["realcom"]
argsdict_default["dict"] = botcommands.get_command_dict(argsdict_default["realcom"], trigger_command_type)
# split into && groupings
and_split = trigger_and_split(trigger_args)
@ -52,9 +65,14 @@ def prerun(t_command_type='module', t_command_subtype=None):
argsdict_list = trigger_argsdict_list(argsdict_default, and_split)
# Run the function for all splits
botmessagelog.messagelog_start(bot, trigger, argsdict_default["log_id"])
runcount = 0
for argsdict in argsdict_list:
runcount += 1
trigger.sb = copy.deepcopy(argsdict)
trigger.sb["runcount"] = runcount
trigger.sb["args"], trigger.sb["hyphen_arg"] = trigger_hyphen_args(trigger.sb["args"])
if not trigger.sb["hyphen_arg"]:
# check if anything prohibits the nick from running the command
@ -62,6 +80,7 @@ def prerun(t_command_type='module', t_command_subtype=None):
function(bot, trigger, *args, **kwargs)
else:
trigger_hyphen_arg_handler(bot, trigger)
botmessagelog.messagelog_exit(bot, argsdict_default["log_id"])
return internal_prerun
return actual_decorator
@ -121,38 +140,84 @@ def trigger_runstatus(bot, trigger):
if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
return True
else:
bot.osd("The admin switch (-a) is for use by authorized nicks ONLY.", 'notice')
botmessagelog.messagelog_error(trigger.sb["log_id"], "The admin switch (-a) is for use by authorized nicks ONLY.")
return False
if trigger.sb["hyphen_arg"]:
return False
if trigger.sb["runcount"] > 1:
# check channel multirun blocks
if not trigger.is_privmsg:
channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender), "multirun")
if trigger.sb["realcom"] in list(channel_disabled_list.keys()):
reason = channel_disabled_list[trigger.sb["realcom"]]["reason"]
timestamp = channel_disabled_list[trigger.sb["realcom"]]["timestamp"]
bywhom = channel_disabled_list[trigger.sb["realcom"]]["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)
return trigger_cant_run(bot, trigger, message)
# don't run commands that are disabled for specific users
nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick), "multirun")
if trigger.sb["realcom"] in list(nick_disabled_list.keys()):
bywhom = nick_disabled_list[trigger.sb["realcom"]]["disabledby"]
if bywhom != trigger.nick:
reason = nick_disabled_list[trigger.sb["realcom"]]["reason"]
timestamp = nick_disabled_list[trigger.sb["realcom"]]["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)
return trigger_cant_run(bot, trigger, message)
else:
botcommands.unset_command_disabled(trigger.sb["realcom"], trigger.nick, "multirun")
botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " multirun is now enabled for " + str(trigger.nick))
# don't run commands that are disabled in channels
if not trigger.is_privmsg:
commandused = trigger.sb["realcom"]
disabled_list = botdb.get_channel_value(trigger.sender, 'commands_disabled') or {}
if commandused in list(disabled_list.keys()):
reason = disabled_list[trigger.sb["realcom"]]["reason"]
timestamp = disabled_list[trigger.sb["realcom"]]["timestamp"]
bywhom = disabled_list[trigger.sb["realcom"]]["disabledby"]
message = "The " + str(trigger.sb["com"]) + " command was disabled by " + bywhom + " in " + str(trigger.sender) + " at " + str(timestamp) + " for the following reason: " + str(reason)
channel_disabled_list = botcommands.get_commands_disabled(str(trigger.sender), "fully")
if trigger.sb["realcom"] in list(channel_disabled_list.keys()):
reason = channel_disabled_list[trigger.sb["realcom"]]["reason"]
timestamp = channel_disabled_list[trigger.sb["realcom"]]["timestamp"]
bywhom = channel_disabled_list[trigger.sb["realcom"]]["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)
return trigger_cant_run(bot, trigger, message)
# don't run commands that are disabled for specific users
nick_disabled_list = botcommands.get_commands_disabled(str(trigger.nick), "fully")
if trigger.sb["realcom"] in list(nick_disabled_list.keys()):
bywhom = nick_disabled_list[trigger.sb["realcom"]]["disabledby"]
if bywhom != trigger.nick:
reason = nick_disabled_list[trigger.sb["realcom"]]["reason"]
timestamp = nick_disabled_list[trigger.sb["realcom"]]["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)
return trigger_cant_run(bot, trigger, message)
else:
botcommands.unset_command_disabled(trigger.sb["realcom"], trigger.nick, "fully")
botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " multirun is now enabled for " + str(trigger.nick))
return True
def trigger_cant_run(bot, trigger, message=None):
if message:
bot.osd(message, trigger.nick, 'notice')
botmessagelog.messagelog_error(trigger.sb["log_id"], message)
if command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
bot.osd("You however are authorized to bypass this warning with the (-a) admin switch.", trigger.nick, 'notice')
botmessagelog.messagelog_error(trigger.sb["log_id"], "You however are authorized to bypass this warning with the (-a) admin switch.")
return False
def trigger_hyphen_args(trigger_args_part):
valid_hyphen_args = [
'check',
'enable', 'disable'
'enable', 'disable',
'block', 'unblock',
"activate", "deactivate",
"on", "off",
'multirun', 'multiruns',
'example', 'usage',
'filename', 'filepath',
'foldername', 'folderpath',
"author",
'contribs', 'contrib', "contributors",
'alias', 'aliases'
]
hyphen_args = []
trigger_args_unhyphend = []
@ -173,48 +238,133 @@ def trigger_hyphen_arg_handler(bot, trigger):
# Commands that cannot run via privmsg
if trigger.sb["hyphen_arg"] in ['check']:
if trigger.sb["com"].lower() != trigger.sb["realcom"]:
bot.osd(trigger.sb["com"] + " is a valid alias command for " + trigger.sb["realcom"])
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is a valid alias command for " + trigger.sb["realcomtext"])
else:
bot.osd(trigger.sb["com"] + " is a valid command")
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is a valid command")
return
elif trigger.sb["hyphen_arg"] in ['enable']:
elif trigger.sb["hyphen_arg"] in [
'enable', 'disable',
'block', 'unblock',
"activate", "deactivate",
"on", "off"
]:
target = spicemanip.main(trigger.sb["args"], 1) or trigger.nick
if not target:
if trigger.sb["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]:
botmessagelog.messagelog_error(trigger.sb["log_id"], "Who/Where am I enabling " + str(trigger.sb["comtext"]) + " usage for?")
else:
botmessagelog.messagelog_error(trigger.sb["log_id"], "Who/Where am I disabling " + str(trigger.sb["comtext"]) + " usage for?")
return
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.")
return
if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
bot.osd("I was unable to disable this command due to privilege issues.")
if target != trigger.nick:
if trigger.sb["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]:
botmessagelog.messagelog_error(trigger.sb["log_id"], "I was unable to enable this command for " + str(target) + " due to privilege issues.")
else:
botmessagelog.messagelog_error(trigger.sb["log_id"], "I was unable to disable this command for " + str(target) + " due to privilege issues.")
return
if trigger.sb["hyphen_arg"] in ['enable', 'unblock', "activate", "on"]:
if not botcommands.check_commands_disabled(trigger.sb["realcom"], target, "fully"):
botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is already enabled for " + str(target))
return
botcommands.unset_command_disabled(trigger.sb["realcom"], target, "fully")
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is now enabled for " + str(target))
return
if trigger.is_privmsg:
bot.osd("This command must be run in a channel you which to enable it in.", trigger.nick, 'notice')
else:
if botcommands.check_commands_disabled(trigger.sb["realcom"], target, "fully"):
botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " is already disabled for " + str(target))
return
trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given."
timestamp = str(datetime.datetime.utcnow())
botcommands.set_command_disabled(trigger.sb["realcom"], target, timestamp, trailingmessage, trigger.nick, "fully")
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " is now disabled for " + str(target))
return
if not botcommands.check_commands_disabled(trigger.sb["realcom"], trigger.sender):
bot.osd(trigger.sb["com"] + " is already enabled in " + str(trigger.sender), trigger.nick, 'notice')
if trigger.sb["hyphen_arg"] in ['multirun', 'multiruns']:
onoff = spicemanip.main(trigger.sb["args"], 1) or None
if not onoff or onoff not in ['enable', 'unblock', "activate", "on"]:
botmessagelog.messagelog_error(trigger.sb["log_id"], "Do you want to enable or disable " + str(trigger.sb["comtext"]) + " multirun usage?")
return
botcommands.unset_command_disabled(trigger.sb["realcom"], trigger.sender)
bot.osd(trigger.sb["com"] + " is now enabled in " + str(trigger.sender))
target = spicemanip.main(trigger.sb["args"], 1) or trigger.nick
if not target:
if onoff in ['enable', 'unblock', "activate", "on"]:
botmessagelog.messagelog_error(trigger.sb["log_id"], "Who/Where am I enabling " + str(trigger.sb["comtext"]) + " multirun usage for?")
else:
botmessagelog.messagelog_error(trigger.sb["log_id"], "Who/Where am I disabling " + str(trigger.sb["comtext"]) + " multirun usage for?")
return
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.")
return
if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
if target != trigger.nick:
if onoff in ['enable', 'unblock', "activate", "on"]:
botmessagelog.messagelog_error(trigger.sb["log_id"], "I was unable to enable multirun usage on " + str(trigger.sb["comtext"]) + " for " + str(target) + " due to privilege issues.")
else:
botmessagelog.messagelog_error(trigger.sb["log_id"], "I was unable to enable multirun usage on " + str(trigger.sb["comtext"]) + " for " + str(target) + " due to privilege issues.")
return
if onoff in ['enable', 'unblock', "activate", "on"]:
if not botcommands.check_commands_disabled(trigger.sb["realcom"], target, "multirun"):
botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " multirun is already enabled for " + str(target))
return
botcommands.unset_command_disabled(trigger.sb["realcom"], target, "multirun")
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " multirun is now enabled for " + str(target))
return
else:
if botcommands.check_commands_disabled(trigger.sb["realcom"], target, "multirun"):
botmessagelog.messagelog_error(trigger.sb["log_id"], trigger.sb["comtext"] + " multirun is already disabled for " + str(target))
return
trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given."
timestamp = str(datetime.datetime.utcnow())
botcommands.set_command_disabled(trigger.sb["realcom"], target, timestamp, trailingmessage, trigger.nick, "multirun")
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + " multirun is now disabled for " + str(target))
return
elif trigger.sb["hyphen_arg"] in ['example', 'usage']:
botmessagelog.messagelog(trigger.sb["log_id"], trigger.sb["comtext"] + ": " + str(trigger.sb["dict"]["example"]))
return
elif trigger.sb["hyphen_arg"] in ['disable']:
elif trigger.sb["hyphen_arg"] in ['filename', 'filepath']:
botmessagelog.messagelog(trigger.sb["log_id"], "The " + str(trigger.sb["comtext"]) + " file is located at " + str(trigger.sb["dict"][trigger.sb["hyphen_arg"]]))
return
if not command_permissions_check(bot, trigger, ['admins', 'owner', 'OP', 'ADMIN', 'OWNER']):
bot.osd("I was unable to disable this command due to privilege issues.")
return
elif trigger.sb["hyphen_arg"] in ['foldername', 'folderpath']:
botmessagelog.messagelog(trigger.sb["log_id"], "The " + str(trigger.sb["comtext"]) + " folder is located at " + str(trigger.sb["dict"][trigger.sb["hyphen_arg"]]))
return
if trigger.is_privmsg:
bot.osd("This command must be run in a channel you which to disable it in.", trigger.nick, 'notice')
return
elif trigger.sb["hyphen_arg"] in ['author']:
botmessagelog.messagelog(trigger.sb["log_id"], "The author of the " + str(trigger.sb["comtext"]) + " command is " + trigger.sb["dict"]["author"] + ".")
return
if botcommands.check_commands_disabled(trigger.sb["realcom"], trigger.sender):
bot.osd(trigger.sb["com"] + " is already disabled in " + str(trigger.sender), trigger.nick, 'notice')
return
elif trigger.sb["hyphen_arg"] in ['contribs', 'contrib', "contributors"]:
botmessagelog.messagelog(trigger.sb["log_id"], "The contributors of the " + str(trigger.sb["comtext"]) + " command are " + spicemanip.main(trigger.sb["dict"]["contributors"], "andlist") + ".")
return
trailingmessage = spicemanip.main(trigger.sb["args"], 0) or "No reason given."
timestamp = str(datetime.datetime.utcnow())
botcommands.set_command_disabled(trigger.sb["realcom"], trigger.sender, timestamp, trailingmessage, trigger.nick)
bot.osd(trigger.sb["com"] + " is now disabled in " + str(trigger.sender))
elif trigger.sb["hyphen_arg"] in ['alias', 'aliases']:
botmessagelog.messagelog(trigger.sb["log_id"], "The alaises of the " + str(trigger.sb["comtext"]) + " command are " + spicemanip.main(trigger.sb["dict"]["validcoms"], "andlist") + ".")
return
return

View File

@ -231,5 +231,9 @@ class BotUsers():
def targetcheck(self):
return True
# idk whois
if not botdb.check_nick_id(posstarget):
return
users = BotUsers()

View File

@ -9,6 +9,7 @@ This module contains references only for other modules to utilize.
from .Config import *
from .Logs import *
from .Database import *
from .MessageLog import *
from .Update import *
from .osd import *

View File

@ -21,7 +21,7 @@ from .AI import *
from .Gif import *
from .Sherlock import *
from .Reddit import *
# from .DictComs import *
from .DictComs import *
__author__ = 'Sam Zick'
__email__ = 'sam@deathbybandaid.net'