|
@@ -1,5 +1,6 @@
|
|
|
from common import userstatus
|
|
from common import userstatus
|
|
|
from commands.common import CommandHelpers as CH
|
|
from commands.common import CommandHelpers as CH
|
|
|
|
|
+from commands.common import AdminHelpers as AH
|
|
|
bold = "\x02"
|
|
bold = "\x02"
|
|
|
italic = "\x1D"
|
|
italic = "\x1D"
|
|
|
underline = "\x1F"
|
|
underline = "\x1F"
|
|
@@ -206,52 +207,73 @@ def do_command(self, connection, event):
|
|
|
if cmdtype == "help": #Display help text. # Help code block first, as it is impossible to predict for what channel a later command is going to be issued. Rights filtering after help test.
|
|
if cmdtype == "help": #Display help text. # Help code block first, as it is impossible to predict for what channel a later command is going to be issued. Rights filtering after help test.
|
|
|
if len(command.split()) is not 1:
|
|
if len(command.split()) is not 1:
|
|
|
return
|
|
return
|
|
|
- connection.privmsg(replyto, "Display or toggle the status channel functions. Channel, function and value optional.")
|
|
|
|
|
|
|
+ connection.privmsg(replyto, "Display or toggle the status channel functions. Channel, function and value optional. Get a description of a functio via the help argument.")
|
|
|
connection.privmsg(replyto, grey + "Usage: " + blue + "!channelfunctions " + red + italic + "channel " + reset + italic + "function value")
|
|
connection.privmsg(replyto, grey + "Usage: " + blue + "!channelfunctions " + red + italic + "channel " + reset + italic + "function value")
|
|
|
|
|
+ connection.privmsg(replyto, grey + "Usage: " + blue + "!channelfunctions help" + italic + "function")
|
|
|
elif cmdtype == "cmd":
|
|
elif cmdtype == "cmd":
|
|
|
if len(command.split()) == 1: # No arguments.
|
|
if len(command.split()) == 1: # No arguments.
|
|
|
if event.target == connection.get_nickname(): # Command issued via PM.
|
|
if event.target == connection.get_nickname(): # Command issued via PM.
|
|
|
connection.privmsg(replyto, "Nothing to display, Specify a channel.")
|
|
connection.privmsg(replyto, "Nothing to display, Specify a channel.")
|
|
|
else: # Command issued as channel message.
|
|
else: # Command issued as channel message.
|
|
|
- message = CH.get_channelfunctions(self, event.target)
|
|
|
|
|
|
|
+ message = AH.get_channelfunctions(self, event.target)
|
|
|
connection.privmsg(replyto, message)
|
|
connection.privmsg(replyto, message)
|
|
|
elif len(command.split()) == 2: # One argument.
|
|
elif len(command.split()) == 2: # One argument.
|
|
|
- if command.split()[1] in self.channels: # Info requested on specific channel.
|
|
|
|
|
- message = CH.get_channelfunctions(self, command.split()[1])
|
|
|
|
|
|
|
+ if command.split()[1].lower() in self.channels.lower(): # Info requested on specific channel.
|
|
|
|
|
+ message = AH.get_channelfunctions(self, command.split()[1])
|
|
|
connection.privmsg(replyto, message)
|
|
connection.privmsg(replyto, message)
|
|
|
else: # First argument is not a channel the bot inhabits.
|
|
else: # First argument is not a channel the bot inhabits.
|
|
|
- connection.privmsg(replyto, command.split()[1] + " is not a channel I inhabit. For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|
|
|
|
|
|
|
+ if not command.split()[1].lower() == "help": # Not a help request.
|
|
|
|
|
+ connection.privmsg(replyto, command.split()[1] + " is not a channel I inhabit. For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|
|
|
|
|
+ else: # Help request.
|
|
|
|
|
+ connection.privmsg(replyto, "Specify a channel function to get a description of. For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|
|
|
elif len(command.split()) == 3: # Two arguments.
|
|
elif len(command.split()) == 3: # Two arguments.
|
|
|
if event.target == connection.get_nickname(): # Command issued via PM.
|
|
if event.target == connection.get_nickname(): # Command issued via PM.
|
|
|
connection.privmsg(replyto, "One or three arguments required. For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|
|
connection.privmsg(replyto, "One or three arguments required. For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|
|
|
else: # Command issued via channel.
|
|
else: # Command issued via channel.
|
|
|
- if not CH.is_channelfunction(self, command.split()[1]): # First argument is not a channelfunction.
|
|
|
|
|
- connection.privmsg(replyto, command.split()[1] + " is not a channel function. For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|
|
|
|
|
- return
|
|
|
|
|
- if not command.split()[2].lower() in ["on", "off"] and not command.split()[1].lower() == "aggressiveness": # Second argument unsupported.
|
|
|
|
|
- connection.privmsg(replyto, "The value of this channel function can only be \"on\" or \"off\". For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|
|
|
|
|
|
|
+ if not AH.is_channelfunction(command.split()[1]): # First argument is not a channelfunction.
|
|
|
|
|
+ if not command.split()[1].lower() == "help": # Not a help request.
|
|
|
|
|
+ connection.privmsg(replyto, command.split()[1] + " is not a channel function. For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|
|
|
|
|
+ return
|
|
|
|
|
+ if not AH.is_channelhunction(self, command.split()[2]): # Second argument not a channel function.
|
|
|
|
|
+ connection.privmsg(replyto, command.split()[2] + " is not a channel function.")
|
|
|
|
|
+ return
|
|
|
|
|
+ connection.privmsg(replyto, AH.describe_channelfunction(command.split()[2]))
|
|
|
return
|
|
return
|
|
|
|
|
+ # Second argument unsupported.
|
|
|
|
|
+ if not command.split()[2].lower() in ["on", "off"]:
|
|
|
|
|
+ if not command.split()[1].lower() == "aggressiveness":
|
|
|
|
|
+ if not AH.is_aggressiveness(command.split()[2]): # Is not an aggressiveness setting.
|
|
|
|
|
+ connection.privmsg(replyto, command.split()[2] + " is not an aggressiveness setting. For help type " + blue + self.helpchat + "channelfunctions" + reset + ".")
|
|
|
|
|
+ return
|
|
|
|
|
+ else: # Channel function is not aggresiveness.
|
|
|
|
|
+ connection.privmsg(replyto, "The value of this channel function can only be \"on\" or \"off\". For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|
|
|
|
|
+ return
|
|
|
if not userstatus.atleast_oper(self, event.source.nick, self.homechannel) and not userstatus.atleast_oper(self, event.source.nick, event.target): # Does not have operator status or higher in target or home channel.
|
|
if not userstatus.atleast_oper(self, event.source.nick, self.homechannel) and not userstatus.atleast_oper(self, event.source.nick, event.target): # Does not have operator status or higher in target or home channel.
|
|
|
connection.privmsg(replyto, "Denied. You need to have at least operator status in " + red + event.target + reset + " or " + red + self.homechannel + reset + ".")
|
|
connection.privmsg(replyto, "Denied. You need to have at least operator status in " + red + event.target + reset + " or " + red + self.homechannel + reset + ".")
|
|
|
return
|
|
return
|
|
|
|
|
+ if command.split()[1].lower() == "autojoin" and event.target == self.homechannel: # Chaning autojoin of homechannel.
|
|
|
|
|
+ connection.action(replyto, "will always join it's homechannel " + red + self.homechannel + reset + ", regardless of the autojoin function.")
|
|
|
self.db.run("UPDATE channels SET " + command.split()[1].lower() + "='" + command.split()[2].lower() + "' WHERE name='" + event.target + "' AND network='" + self.network + "'")
|
|
self.db.run("UPDATE channels SET " + command.split()[1].lower() + "='" + command.split()[2].lower() + "' WHERE name='" + event.target + "' AND network='" + self.network + "'")
|
|
|
elif len(command.split()) == 4: # Three arguments.
|
|
elif len(command.split()) == 4: # Three arguments.
|
|
|
if not command.split()[1] in self.channels: # Bot does not inhabit channel to be altered.
|
|
if not command.split()[1] in self.channels: # Bot does not inhabit channel to be altered.
|
|
|
connection.privmsg(replyto, command.split()[1] + " is not a channel I inhabit. For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|
|
connection.privmsg(replyto, command.split()[1] + " is not a channel I inhabit. For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|
|
|
return
|
|
return
|
|
|
- if not CH.is_channelfunction(self, command.split()[2]): # Function does not exist.
|
|
|
|
|
|
|
+ if not AH.is_channelfunction(command.split()[2]): # Function does not exist.
|
|
|
connection.privmsg(replyto, command.split()[2] + " is not a valid channel function. For a list help type: " + blue + self.cmdchar + "channelfunctions" + red + italic + "channel")
|
|
connection.privmsg(replyto, command.split()[2] + " is not a valid channel function. For a list help type: " + blue + self.cmdchar + "channelfunctions" + red + italic + "channel")
|
|
|
return
|
|
return
|
|
|
|
|
+
|
|
|
if not command.split()[3].lower() in ["on", "off"] and not command.split()[2].lower() == "aggressiveness": # Third argument unsupported.
|
|
if not command.split()[3].lower() in ["on", "off"] and not command.split()[2].lower() == "aggressiveness": # Third argument unsupported.
|
|
|
connection.privmsg(replyto, "The value of this channel function can only be \"on\" or \"off\". For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|
|
connection.privmsg(replyto, "The value of this channel function can only be \"on\" or \"off\". For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|
|
|
return
|
|
return
|
|
|
if not userstatus.atleast_oper(self, event.source.nick, self.homechannel) and not userstatus.atleast_oper(self, event.source.nick, command.split()[1]): # Does not have operator status or higher in target or home channel.
|
|
if not userstatus.atleast_oper(self, event.source.nick, self.homechannel) and not userstatus.atleast_oper(self, event.source.nick, command.split()[1]): # Does not have operator status or higher in target or home channel.
|
|
|
connection.privmsg(replyto, "Denied. You need to have at least operator status in " + red + event.target + reset + " or " + red + self.homechannel + reset + ".")
|
|
connection.privmsg(replyto, "Denied. You need to have at least operator status in " + red + event.target + reset + " or " + red + self.homechannel + reset + ".")
|
|
|
return
|
|
return
|
|
|
|
|
+ if command.split()[2].lower() == "autojoin" and command.split()[1] == self.homechannel: # Chaning autojoin of homechannel.
|
|
|
|
|
+ connection.action(replyto, "will always join it's homechannel " + red + self.homechannel + reset + ", regardless of the autojoin function.")
|
|
|
try:
|
|
try:
|
|
|
self.db.run("UPDATE channels SET " + command.split()[2].lower() + "='" + command.split()[3].lower() + "' WHERE LOWER(name)=LOWER('" + command.split()[1] + "') AND network='" + self.network + "'")
|
|
self.db.run("UPDATE channels SET " + command.split()[2].lower() + "='" + command.split()[3].lower() + "' WHERE LOWER(name)=LOWER('" + command.split()[1] + "') AND network='" + self.network + "'")
|
|
|
except:
|
|
except:
|
|
|
connection.privmsg(replyto, "Error, database record not updated.")
|
|
connection.privmsg(replyto, "Error, database record not updated.")
|
|
|
return
|
|
return
|
|
|
- else:
|
|
|
|
|
|
|
+ else: # Too many arguments.
|
|
|
connection.privmsg(replyto, "Too many arguments. For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|
|
connection.privmsg(replyto, "Too many arguments. For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|