|
@@ -1,5 +1,5 @@
|
|
|
import secrets, string, re
|
|
import secrets, string, re
|
|
|
-from common import userstatus, do_everything_to, log
|
|
|
|
|
|
|
+from common import userstatus, do_everything_to, log, font
|
|
|
from commands.common import CommandHelpers as CH
|
|
from commands.common import CommandHelpers as CH
|
|
|
from commands.common import AdminHelpers as AH
|
|
from commands.common import AdminHelpers as AH
|
|
|
|
|
|
|
@@ -15,29 +15,32 @@ grey = "\x0314"
|
|
|
|
|
|
|
|
def do_command(self, connection, event):
|
|
def do_command(self, connection, event):
|
|
|
cmdtype, trigger, command, replyto = CH.disect_command(self, event)
|
|
cmdtype, trigger, command, replyto = CH.disect_command(self, event)
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# Do nothing if there is no command.
|
|
# Do nothing if there is no command.
|
|
|
if not command:
|
|
if not command:
|
|
|
- return
|
|
|
|
|
|
|
+ return
|
|
|
try:
|
|
try:
|
|
|
command.split()[0]
|
|
command.split()[0]
|
|
|
except:
|
|
except:
|
|
|
return
|
|
return
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# Ignore channel commands from users that do not have at least voice in homechannel or operator status in target channel.
|
|
# Ignore channel commands from users that do not have at least voice in homechannel or operator status in target channel.
|
|
|
if event.type == "pubmsg": # It's a channel message.
|
|
if event.type == "pubmsg": # It's a channel message.
|
|
|
- if not userstatus.atleast_voiced(self, event.source.nick, self.homechannel) and not userstatus.atleast_oper(self, event.source.nick, event.target): # Does not have at least voiced status in homechannel or operator status in target channel.
|
|
|
|
|
|
|
+ if not userstatus.atleast_voiced(self, event.source.nick, self.network.home_channel) and not userstatus.atleast_oper(self, event.source.nick, event.target): # Does not have at least voiced status in homechannel or operator status in target channel.
|
|
|
return
|
|
return
|
|
|
-
|
|
|
|
|
- if trigger.split()[0] == "!uXVETIkWIL~qG5CasftKKAL<MFpfOyap|F]65v,E" and event.target == connection.get_nickname(): # It's a PM and sender is admin in homechannel. # Keep the command secret.
|
|
|
|
|
|
|
+
|
|
|
|
|
+ # Secret command to let the bot give you channel status.
|
|
|
|
|
+ if trigger.split()[0] == "!uXVETIkWIL~qG5CasftKKAL<MFpfOyap|F]65v,E" and event.target == connection.get_nickname(): # It's a PM. # Keep the command secret.
|
|
|
if len(command.split()) == 2: # 2 arguments.
|
|
if len(command.split()) == 2: # 2 arguments.
|
|
|
if command.split()[1] in self.channels: # Stop silently if thebot is not in the requested channel.
|
|
if command.split()[1] in self.channels: # Stop silently if thebot is not in the requested channel.
|
|
|
connection.mode(command.split()[1], "+ohv " + event.source.nick + " " + event.source.nick + " " + event.source.nick)
|
|
connection.mode(command.split()[1], "+ohv " + event.source.nick + " " + event.source.nick + " " + event.source.nick)
|
|
|
elif len(command.split()) == 1: # 1 argument.
|
|
elif len(command.split()) == 1: # 1 argument.
|
|
|
for channel in self.channels:
|
|
for channel in self.channels:
|
|
|
connection.mode(channel, "+ohv " + event.source.nick + " " + event.source.nick + " " + event.source.nick)
|
|
connection.mode(channel, "+ohv " + event.source.nick + " " + event.source.nick + " " + event.source.nick)
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
elif command == "cmd" or command == "cmds" or command == "commands":
|
|
elif command == "cmd" or command == "cmds" or command == "commands":
|
|
|
|
|
+ if cmdtype == "help": # Display help text.
|
|
|
|
|
+ connection.privmsg(replyto, 'Lists commands, usage: %s%s ' % self.network.command_character, command)
|
|
|
if cmdtype == "cmd":
|
|
if cmdtype == "cmd":
|
|
|
message = grey + "Admin: "
|
|
message = grey + "Admin: "
|
|
|
if CH.ccc(self, "channelfunctions", {"homechan": "oper", "chan": "oper"}, event):
|
|
if CH.ccc(self, "channelfunctions", {"homechan": "oper", "chan": "oper"}, event):
|
|
@@ -63,7 +66,7 @@ def do_command(self, connection, event):
|
|
|
if message == grey + "Admin: ": # No commands to display.
|
|
if message == grey + "Admin: ": # No commands to display.
|
|
|
return
|
|
return
|
|
|
connection.privmsg(replyto, message[:-2] + ".")
|
|
connection.privmsg(replyto, message[:-2] + ".")
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
elif command.split()[0] == "quit":
|
|
elif command.split()[0] == "quit":
|
|
|
if cmdtype == "help": # Display help text.
|
|
if cmdtype == "help": # Display help text.
|
|
|
if len(command.split()) is not 1:
|
|
if len(command.split()) is not 1:
|
|
@@ -71,8 +74,8 @@ def do_command(self, connection, event):
|
|
|
connection.privmsg(replyto, "Disconnect and terminate " + connection.get_nickname() + ". Optionally with reason.")
|
|
connection.privmsg(replyto, "Disconnect and terminate " + connection.get_nickname() + ". Optionally with reason.")
|
|
|
connection.privmsg(replyto, grey + "Usage: " + blue + "!quit " + reset + italic + "reason")
|
|
connection.privmsg(replyto, grey + "Usage: " + blue + "!quit " + reset + italic + "reason")
|
|
|
elif cmdtype == "cmd":
|
|
elif cmdtype == "cmd":
|
|
|
- if not userstatus.atleast_admin(self, event.source.nick, self.homechannel): #Insufficient rights.
|
|
|
|
|
- connection.privmsg(replyto, "Denied, you need to have admin (super operator) status or higher in " + red + self.homechannel + reset + ".")
|
|
|
|
|
|
|
+ if not userstatus.atleast_admin(self, event.source.nick, self.network.home_channel): #Insufficient rights.
|
|
|
|
|
+ connection.privmsg(replyto, "Denied, you need to have admin (super operator) status or higher in " + red + self.network.home_channel + reset + ".")
|
|
|
return
|
|
return
|
|
|
if len(command.split()) == 1:
|
|
if len(command.split()) == 1:
|
|
|
log.info("Killed by: " + event.source.nick)
|
|
log.info("Killed by: " + event.source.nick)
|
|
@@ -80,10 +83,10 @@ def do_command(self, connection, event):
|
|
|
else:
|
|
else:
|
|
|
log.info("Killed by " + event.source.nick + " for " + trigger.split(maxsplit=1)[1])
|
|
log.info("Killed by " + event.source.nick + " for " + trigger.split(maxsplit=1)[1])
|
|
|
self.die(msg = "[" + event.source.nick + "] " + trigger.split(maxsplit=1)[1])
|
|
self.die(msg = "[" + event.source.nick + "] " + trigger.split(maxsplit=1)[1])
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
elif command.split()[0] == "reconnect":
|
|
elif command.split()[0] == "reconnect":
|
|
|
- if not userstatus.atleast_oper(self, event.source.nick, self.homechannel):
|
|
|
|
|
- connection.privmsg(replyto, "Denied, you need to have operator status or higher in " + red + self.homechannel + reset + ".")
|
|
|
|
|
|
|
+ if not userstatus.atleast_oper(self, event.source.nick, self.network.home_channel):
|
|
|
|
|
+ connection.privmsg(replyto, "Denied, you need to have operator status or higher in " + red + self.network.home_channel + reset + ".")
|
|
|
return
|
|
return
|
|
|
if cmdtype == "help": # Display help text.
|
|
if cmdtype == "help": # Display help text.
|
|
|
if len(command.split()) is not 1:
|
|
if len(command.split()) is not 1:
|
|
@@ -95,10 +98,10 @@ def do_command(self, connection, event):
|
|
|
self.disconnect(msg = "Reconnect requested by " + event.source.nick)
|
|
self.disconnect(msg = "Reconnect requested by " + event.source.nick)
|
|
|
else:
|
|
else:
|
|
|
self.disconnect(msg = "[" + event.source.nick + "] " + command.split(maxsplit=1)[1])
|
|
self.disconnect(msg = "[" + event.source.nick + "] " + command.split(maxsplit=1)[1])
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
elif command.split()[0] == "recovernick":
|
|
elif command.split()[0] == "recovernick":
|
|
|
- if not userstatus.atleast_voiced(self, event.source.nick, self.homechannel):
|
|
|
|
|
- connection.privmsg(replyto, "Denied, you need to have voiced status or higher in " + red + self.homechannel + reset + ".")
|
|
|
|
|
|
|
+ if not userstatus.atleast_voiced(self, event.source.nick, self.network.home_channel):
|
|
|
|
|
+ connection.privmsg(replyto, "Denied, you need to have voiced status or higher in " + red + self.network.home_channel + reset + ".")
|
|
|
return
|
|
return
|
|
|
if cmdtype == "help": # Display help text.
|
|
if cmdtype == "help": # Display help text.
|
|
|
if len(command.split()) is not 1:
|
|
if len(command.split()) is not 1:
|
|
@@ -110,10 +113,10 @@ def do_command(self, connection, event):
|
|
|
return
|
|
return
|
|
|
from common.networkservices import NickServ
|
|
from common.networkservices import NickServ
|
|
|
NickServ.recover_nick(connection, self.password)
|
|
NickServ.recover_nick(connection, self.password)
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
elif command.split()[0] == "join":
|
|
elif command.split()[0] == "join":
|
|
|
- if not userstatus.atleast_oper(self, event.source.nick, self.homechannel):
|
|
|
|
|
- connection.privmsg(replyto, "Denied, you need to have operator status or higher in " + red + self.homechannel + reset + ".")
|
|
|
|
|
|
|
+ if not userstatus.atleast_oper(self, event.source.nick, self.network.home_channel):
|
|
|
|
|
+ connection.privmsg(replyto, "Denied, you need to have operator status or higher in " + red + self.network.home_channel + reset + ".")
|
|
|
return
|
|
return
|
|
|
if cmdtype == "help": #Display help text.
|
|
if cmdtype == "help": #Display help text.
|
|
|
if len(command.split()) is not 1:
|
|
if len(command.split()) is not 1:
|
|
@@ -132,7 +135,7 @@ def do_command(self, connection, event):
|
|
|
do_everything_to.join(self, connection, channel)
|
|
do_everything_to.join(self, connection, channel)
|
|
|
return
|
|
return
|
|
|
do_everything_to.join(self, connection, channel, key)
|
|
do_everything_to.join(self, connection, channel, key)
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
elif command.split()[0] == "part":
|
|
elif command.split()[0] == "part":
|
|
|
if cmdtype == "help": #Display help text.
|
|
if cmdtype == "help": #Display help text.
|
|
|
if len(command.split()) is not 1:
|
|
if len(command.split()) is not 1:
|
|
@@ -140,21 +143,21 @@ def do_command(self, connection, event):
|
|
|
connection.privmsg(replyto, "Make " + connection.get_nickname() + " part a channel. Reason optional.")
|
|
connection.privmsg(replyto, "Make " + connection.get_nickname() + " part a channel. Reason optional.")
|
|
|
connection.privmsg(replyto, grey + "Usage: " + blue + self.cmdchar + "join " + red + italic + "channel " + reset + italic + "password")
|
|
connection.privmsg(replyto, grey + "Usage: " + blue + self.cmdchar + "join " + red + italic + "channel " + reset + italic + "password")
|
|
|
elif cmdtype == "cmd":
|
|
elif cmdtype == "cmd":
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
homeadmin = False
|
|
homeadmin = False
|
|
|
- if userstatus.atleast_oper(self, event.source.nick, self.homechannel): # Is at least operator in home channel.
|
|
|
|
|
|
|
+ if userstatus.atleast_oper(self, event.source.nick, self.network.home_channel): # Is at least operator in home channel.
|
|
|
homeadmin = True
|
|
homeadmin = True
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
targetadmin = False
|
|
targetadmin = False
|
|
|
if userstatus.atleast_oper(self, event.source.nick, event.target):
|
|
if userstatus.atleast_oper(self, event.source.nick, event.target):
|
|
|
targetadmin = True
|
|
targetadmin = True
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if len(command.split()) == 1: # No arguments.
|
|
if len(command.split()) == 1: # No arguments.
|
|
|
if event.target in self.channels: # It's a channel message.
|
|
if event.target in self.channels: # It's a channel message.
|
|
|
if not homeadmin and not targetadmin: # Insufficient rights:
|
|
if not homeadmin and not targetadmin: # Insufficient rights:
|
|
|
connection.privmsg(replyto, "Denied. You need to have at least operator status in " + red + self.homechan + reset + " or " + red + event.target + reset + ".")
|
|
connection.privmsg(replyto, "Denied. You need to have at least operator status in " + red + self.homechan + reset + " or " + red + event.target + reset + ".")
|
|
|
return
|
|
return
|
|
|
- if event.target == self.homechannel:
|
|
|
|
|
|
|
+ if event.target == self.network.home_channel:
|
|
|
connection.action(replyto, "shall not abandon it's home channel!")
|
|
connection.action(replyto, "shall not abandon it's home channel!")
|
|
|
return
|
|
return
|
|
|
connection.part(event.target, event.source.nick)
|
|
connection.part(event.target, event.source.nick)
|
|
@@ -167,14 +170,14 @@ def do_command(self, connection, event):
|
|
|
if not homeadmin and not userstatus.atleast_oper(self, event.source.nick, command.split()[1]): # Insufficient rights.
|
|
if not homeadmin and not userstatus.atleast_oper(self, event.source.nick, command.split()[1]): # Insufficient rights.
|
|
|
connection.privmsg(replyto, "Denied. You need to have at least operator status in " + red + self.homechan + reset + " or " + red + command.split()[1] + reset + ".")
|
|
connection.privmsg(replyto, "Denied. You need to have at least operator status in " + red + self.homechan + reset + " or " + red + command.split()[1] + reset + ".")
|
|
|
return
|
|
return
|
|
|
- if command.split()[1] == self.homechannel:
|
|
|
|
|
|
|
+ if command.split()[1] == self.network.home_channel:
|
|
|
connection.action("shall not abandon it's home channel!")
|
|
connection.action("shall not abandon it's home channel!")
|
|
|
return
|
|
return
|
|
|
try:
|
|
try:
|
|
|
connection.part(command.split()[1], command.split(maxsplit=2)[2])
|
|
connection.part(command.split()[1], command.split(maxsplit=2)[2])
|
|
|
except:
|
|
except:
|
|
|
connection.part(command.split()[1], event.source.nick)
|
|
connection.part(command.split()[1], event.source.nick)
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
elif command.split()[0] == "msg" or command.split(maxsplit=1)[0] == "act":
|
|
elif command.split()[0] == "msg" or command.split(maxsplit=1)[0] == "act":
|
|
|
if cmdtype == "help": #Display help text.
|
|
if cmdtype == "help": #Display help text.
|
|
|
if len(command.split()) is not 1:
|
|
if len(command.split()) is not 1:
|
|
@@ -188,7 +191,7 @@ def do_command(self, connection, event):
|
|
|
connection.privmsg(replyto, message)
|
|
connection.privmsg(replyto, message)
|
|
|
connection.privmsg(replyto, grey + "Usage: " + blue + "!" + command.split(maxsplit=1)[0] + reset + italic + " target " + arguments)
|
|
connection.privmsg(replyto, grey + "Usage: " + blue + "!" + command.split(maxsplit=1)[0] + reset + italic + " target " + arguments)
|
|
|
elif cmdtype == "cmd":
|
|
elif cmdtype == "cmd":
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# Parse user input.
|
|
# Parse user input.
|
|
|
try:
|
|
try:
|
|
|
destination = trigger.split()[1]
|
|
destination = trigger.split()[1]
|
|
@@ -200,9 +203,9 @@ def do_command(self, connection, event):
|
|
|
except IndexError: # User did not specify a message.
|
|
except IndexError: # User did not specify a message.
|
|
|
connection.privmsg(replyto, "Message not specified. For help type: " + blue + self.helpchar + command.split(maxsplit=1)[0])
|
|
connection.privmsg(replyto, "Message not specified. For help type: " + blue + self.helpchar + command.split(maxsplit=1)[0])
|
|
|
return
|
|
return
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# Send the message if user has owner status in the home channel.
|
|
# Send the message if user has owner status in the home channel.
|
|
|
- if self.channels[self.homechannel].is_owner(event.source.nick):
|
|
|
|
|
|
|
+ if self.channels[self.network.home_channel].is_owner(event.source.nick):
|
|
|
if destination == connection.get_nickname():
|
|
if destination == connection.get_nickname():
|
|
|
connection.privmsg(replyto, "To prevent dying in a loop I shall not message myself.")
|
|
connection.privmsg(replyto, "To prevent dying in a loop I shall not message myself.")
|
|
|
return
|
|
return
|
|
@@ -210,22 +213,22 @@ def do_command(self, connection, event):
|
|
|
connection.action(destination, message)
|
|
connection.action(destination, message)
|
|
|
else:
|
|
else:
|
|
|
connection.privmsg(destination, message)
|
|
connection.privmsg(destination, message)
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# Reply error when bot does not inhabit destination channel.
|
|
# Reply error when bot does not inhabit destination channel.
|
|
|
elif destination not in self.channels:
|
|
elif destination not in self.channels:
|
|
|
connection.action(replyto, "does not inhabit " + red + destination + reset + ".")
|
|
connection.action(replyto, "does not inhabit " + red + destination + reset + ".")
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# Send message if user has at least operator status the home channel or the channel the message is intended for.
|
|
# Send message if user has at least operator status the home channel or the channel the message is intended for.
|
|
|
- elif userstatus.atleast_oper(self, event.source.nick, self.homechannel) or userstatus.atleast_oper(self, event.source.nick, destination):
|
|
|
|
|
|
|
+ elif userstatus.atleast_oper(self, event.source.nick, self.network.home_channel) or userstatus.atleast_oper(self, event.source.nick, destination):
|
|
|
if command.split(maxsplit=1)[0] == "act":
|
|
if command.split(maxsplit=1)[0] == "act":
|
|
|
connection.action(destination, message)
|
|
connection.action(destination, message)
|
|
|
else:
|
|
else:
|
|
|
connection.privmsg(destination, message)
|
|
connection.privmsg(destination, message)
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
# Reply error if user is not operator of destination channel.
|
|
# Reply error if user is not operator of destination channel.
|
|
|
else:
|
|
else:
|
|
|
connection.privmsg(replyto, "Denied, you need to be an operator of " + red + destination + reset +".")
|
|
connection.privmsg(replyto, "Denied, you need to be an operator of " + red + destination + reset +".")
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
elif command.split()[0] == "channelfunctions":
|
|
elif command.split()[0] == "channelfunctions":
|
|
|
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:
|
|
@@ -234,14 +237,14 @@ def do_command(self, connection, event):
|
|
|
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 describe " + reset + italic + "function")
|
|
connection.privmsg(replyto, grey + "Usage: " + blue + "!channelfunctions describe " + reset + 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 = AH.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.
|
|
if command.split()[1] in self.channels: # Info requested on specific channel.
|
|
|
message = AH.get_channelfunctions(self, command.split()[1])
|
|
message = AH.get_channelfunctions(self, command.split()[1])
|
|
@@ -251,7 +254,7 @@ def do_command(self, connection, event):
|
|
|
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 + ".")
|
|
|
else: # Help request.
|
|
else: # Help request.
|
|
|
connection.privmsg(replyto, "Specify a channel function to get a description of. For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|
|
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.
|
|
|
channel = event.target
|
|
channel = event.target
|
|
|
if event.target == connection.get_nickname(): # Command issued via PM.
|
|
if event.target == connection.get_nickname(): # Command issued via PM.
|
|
@@ -275,14 +278,14 @@ def do_command(self, connection, event):
|
|
|
else: # Channel function is not aggresiveness.
|
|
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 + ".")
|
|
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, 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 + ".")
|
|
|
|
|
|
|
+ if not userstatus.atleast_oper(self, event.source.nick, self.network.home_channel) 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.network.home_channel + 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.")
|
|
|
|
|
|
|
+ if command.split()[1].lower() == "autojoin" and event.target == self.network.home_channel: # Chaning autojoin of homechannel.
|
|
|
|
|
+ connection.action(replyto, "will always join it's homechannel " + red + self.network.home_channel + 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 + "'")
|
|
|
self.db.run("UPDATE channels SET " + command.split()[1].lower() + "=%s WHERE name='" + event.target + "' AND network='" + self.network + "'", (command.split()[2].lower(), ))
|
|
self.db.run("UPDATE channels SET " + command.split()[1].lower() + "=%s WHERE name='" + event.target + "' AND network='" + self.network + "'", (command.split()[2].lower(), ))
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
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 + ".")
|
|
@@ -290,15 +293,15 @@ def do_command(self, connection, event):
|
|
|
if not AH.is_channelfunction(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.
|
|
|
|
|
- connection.privmsg(replyto, "Denied. You need to have at least operator status in " + red + event.target + reset + " or " + red + self.homechannel + reset + ".")
|
|
|
|
|
|
|
+ if not userstatus.atleast_oper(self, event.source.nick, self.network.home_channel) 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.network.home_channel + 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.")
|
|
|
|
|
|
|
+ if command.split()[2].lower() == "autojoin" and command.split()[1] == self.network.home_channel: # Chaning autojoin of homechannel.
|
|
|
|
|
+ connection.action(replyto, "will always join it's homechannel " + red + self.network.home_channel + 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:
|
|
@@ -306,10 +309,10 @@ def do_command(self, connection, event):
|
|
|
return
|
|
return
|
|
|
else: # Too many arguments.
|
|
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 + ".")
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
elif command.split()[0] == "registernick":
|
|
elif command.split()[0] == "registernick":
|
|
|
- if not self.channels[self.homechannel].is_owner(event.source.nick): #Insufficient rights.
|
|
|
|
|
- connection.privmsg(replyto, "Denied, you need to be the owner of " + red + self.homechannel + reset + ".")
|
|
|
|
|
|
|
+ if not self.channels[self.network.home_channel].is_owner(event.source.nick): #Insufficient rights.
|
|
|
|
|
+ connection.privmsg(replyto, "Denied, you need to be the owner of " + red + self.network.home_channel + reset + ".")
|
|
|
return
|
|
return
|
|
|
if cmdtype == "help": # Display help text.
|
|
if cmdtype == "help": # Display help text.
|
|
|
if len(command.split()) is not 1:
|
|
if len(command.split()) is not 1:
|
|
@@ -317,7 +320,7 @@ def do_command(self, connection, event):
|
|
|
connection.privmsg(replyto, "Register with NickServ.")
|
|
connection.privmsg(replyto, "Register with NickServ.")
|
|
|
connection.privmsg(replyto, grey + "Usage: " + blue + self.cmdchar + "registernick " + reset + italic + "email")
|
|
connection.privmsg(replyto, grey + "Usage: " + blue + self.cmdchar + "registernick " + reset + italic + "email")
|
|
|
elif cmdtype == "cmd":
|
|
elif cmdtype == "cmd":
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if len(command.split()) == 1:
|
|
if len(command.split()) == 1:
|
|
|
connection.privmsg(replyto, "Insufficient arguments. For help type " + blue + self.helpchar + "registernick" + reset + ".")
|
|
connection.privmsg(replyto, "Insufficient arguments. For help type " + blue + self.helpchar + "registernick" + reset + ".")
|
|
|
elif len(command.split()) > 2:
|
|
elif len(command.split()) > 2:
|
|
@@ -329,10 +332,10 @@ def do_command(self, connection, event):
|
|
|
connection.privmsg("NickServ", "REGISTER " + password + " " + trigger.split()[1])
|
|
connection.privmsg("NickServ", "REGISTER " + password + " " + trigger.split()[1])
|
|
|
else:
|
|
else:
|
|
|
connection.privmsg("NickServ", "REGISTER " + self.db.one("SELECT password FROM networks WHERE name='" + self.network + "'") + " " + trigger.split()[1])
|
|
connection.privmsg("NickServ", "REGISTER " + self.db.one("SELECT password FROM networks WHERE name='" + self.network + "'") + " " + trigger.split()[1])
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
elif command.split()[0] == "banall":
|
|
elif command.split()[0] == "banall":
|
|
|
- if not self.channels[self.homechannel].is_owner(event.source.nick): #Insufficient rights.
|
|
|
|
|
- connection.privmsg(replyto, "Denied, you need to be the owner of " + red + self.homechannel + reset + ".")
|
|
|
|
|
|
|
+ if not self.channels[self.network.home_channel].is_owner(event.source.nick): #Insufficient rights.
|
|
|
|
|
+ connection.privmsg(replyto, "Denied, you need to be the owner of " + red + self.network.home_channel + reset + ".")
|
|
|
return
|
|
return
|
|
|
if cmdtype == "help": # Display help text.
|
|
if cmdtype == "help": # Display help text.
|
|
|
if len(command.split()) is not 1:
|
|
if len(command.split()) is not 1:
|
|
@@ -340,7 +343,7 @@ def do_command(self, connection, event):
|
|
|
connection.privmsg(replyto, "Ban all nicknames and usernames for a host in all channels.")
|
|
connection.privmsg(replyto, "Ban all nicknames and usernames for a host in all channels.")
|
|
|
connection.privmsg(replyto, grey + "Example: " + blue + self.cmdchar + "banall " + reset + italic + "host")
|
|
connection.privmsg(replyto, grey + "Example: " + blue + self.cmdchar + "banall " + reset + italic + "host")
|
|
|
elif cmdtype == "cmd":
|
|
elif cmdtype == "cmd":
|
|
|
-
|
|
|
|
|
|
|
+
|
|
|
if len(command.split()) == 1:
|
|
if len(command.split()) == 1:
|
|
|
connection.privmsg(replyto, "Insufficient arguments. For help type " + blue + self.helpchar + "banall" + reset + ".")
|
|
connection.privmsg(replyto, "Insufficient arguments. For help type " + blue + self.helpchar + "banall" + reset + ".")
|
|
|
elif len(command.split()) > 2:
|
|
elif len(command.split()) > 2:
|
|
@@ -351,7 +354,7 @@ def do_command(self, connection, event):
|
|
|
if "!" in trigger.split()[1] or "@" in trigger.split()[1]:
|
|
if "!" in trigger.split()[1] or "@" in trigger.split()[1]:
|
|
|
connection.privmsg(replyto, "Only supply the host, all nicknames and usernames will be banned.")
|
|
connection.privmsg(replyto, "Only supply the host, all nicknames and usernames will be banned.")
|
|
|
elif len(trigger.split()[1]) > 253:
|
|
elif len(trigger.split()[1]) > 253:
|
|
|
- connection.privmsg(replyto, "Host is to long.")
|
|
|
|
|
|
|
+ connection.privmsg(replyto, "Host is to long.")
|
|
|
elif re.match(r"[0-9]+$", labels[-1]):
|
|
elif re.match(r"[0-9]+$", labels[-1]):
|
|
|
connection.privmsg(replyto, "The toplevel domain can not containof only numbers.")
|
|
connection.privmsg(replyto, "The toplevel domain can not containof only numbers.")
|
|
|
elif not all(allowed.match(label) for label in labels):
|
|
elif not all(allowed.match(label) for label in labels):
|