|
|
@@ -1,3 +1,4 @@
|
|
|
+from common import userstatus
|
|
|
from commands.common import CommandHelpers as CH
|
|
|
bold = "\x02"
|
|
|
italic = "\x1D"
|
|
|
@@ -19,7 +20,15 @@ def do_command(self, connection, event):
|
|
|
|
|
|
if command == "cmd" or command == "commands":
|
|
|
if cmdtype == "cmd":
|
|
|
- connection.privmsg(replyto, grey + "Admin: " + CH.ccc(self, "channelfunctions", {"homechan": "oper", "chan": "oper"}, event) + CH.ccc(self, "join", {"homechan": "oper", "chan": None}, event) + CH.ccc(self, "die", {"homechan": "admin", "chan": None}, event) + CH.ccc(self, "reconnect", {"homechan": "oper", "chan": None}, event) + CH.ccc(self, "recovernick", {"homechan": "oper", "chan": None}, event)+ CH.ccc(self, "msg", {"homechan": "oper", "chan": "oper"}, event) + CH.ccc(self, "act", {"homechan": "oper", "chan": "oper"}, event)[:-2] + ".")
|
|
|
+ connection.privmsg(replyto, grey + "Admin: "
|
|
|
+ + CH.ccc(self, "channelfunctions", {"homechan": "oper", "chan": "oper"}, event)
|
|
|
+ + CH.ccc(self, "join", {"homechan": "oper", "chan": None}, event)
|
|
|
+ + CH.ccc(self, "part", {"homechan": "oper", "chan": None}, event)
|
|
|
+ + CH.ccc(self, "die", {"homechan": "admin", "chan": None}, event)
|
|
|
+ + CH.ccc(self, "reconnect", {"homechan": "oper", "chan": None}, event)
|
|
|
+ + CH.ccc(self, "recovernick", {"homechan": "oper", "chan": None}, event)
|
|
|
+ + CH.ccc(self, "msg", {"homechan": "oper", "chan": "oper"}, event)
|
|
|
+ + CH.ccc(self, "act", {"homechan": "oper", "chan": "oper"}, event)[:-2] + ".")
|
|
|
|
|
|
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.
|
|
|
@@ -76,14 +85,14 @@ def do_command(self, connection, event):
|
|
|
connection.privmsg(replyto, "Too many arguments. For help type " + blue + self.helpchar + "channelfunctions" + reset + ".")
|
|
|
|
|
|
elif command.split()[0] == "join":
|
|
|
- if not self.channels[self.homechannel].is_owner(event.source.nick) and not self.channels[self.homechannel].is_admin(event.source.nick) and not self.channels[self.homechannel].is_oper(event.source.nick):
|
|
|
- connection.privmsg(replyto, "Denied, you need to have admin (super operator) status or higher in " + red + self.homechannel + reset + ".")
|
|
|
+ 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 + ".")
|
|
|
return
|
|
|
if cmdtype == "help": #Display help text.
|
|
|
if len(command.split()) is not 1:
|
|
|
return
|
|
|
connection.privmsg(replyto, "Make " + connection.get_nickname() + " join a channel. Password optional.")
|
|
|
- connection.privmsg(replyto, grey + "Usage: " + blue + "!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":
|
|
|
try:
|
|
|
channel = command.split()[1]
|
|
|
@@ -98,6 +107,43 @@ def do_command(self, connection, event):
|
|
|
print(channel + " | " + key)
|
|
|
connection.join(channel, key=key)
|
|
|
|
|
|
+ elif command.split()[0] == "part":
|
|
|
+ if cmdtype == "help": #Display help text.
|
|
|
+ if len(command.split()) is not 1:
|
|
|
+ return
|
|
|
+ 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")
|
|
|
+ elif cmdtype == "cmd":
|
|
|
+
|
|
|
+ if self.channels[self.homechannel].is_owner(event.source.nick) or self.channels[self.homechannel].is_admin(event.source.nick) or self.channels[self.homechannel].is_oper(event.source.nick): # Is at least operator in home channel.
|
|
|
+ homeadmin = True
|
|
|
+
|
|
|
+ try:
|
|
|
+ if self.channels[event.target].is_owner(event.source.nick) or self.channels[event.target].is_admin(event.source.nick) or self.channels[event.target].is_oper(event.source.nick):
|
|
|
+ targetadmin = True
|
|
|
+ except:
|
|
|
+ pass
|
|
|
+
|
|
|
+ if len(command.split()) == 1: # No arguments.
|
|
|
+ if event.target in self.channels: # It's a channel message.
|
|
|
+ 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 + ".")
|
|
|
+ return
|
|
|
+ connection.part(event.target, event.source.nick)
|
|
|
+ else: # It's a PM.
|
|
|
+ connection.privmsg(replyto, "Specify a channel to part. For help type " + blue + self.helpchar + "part" + reset + ".")
|
|
|
+ elif len(command.split()) > 1: # Arguments
|
|
|
+ if command.split()[1] not in self.channels: # First argument is not a channel the bot inhabits.
|
|
|
+ connection.action(replyto, "does not inhabit " + red + command.split()[1] + reset + ". For help type " + blue + self.helpchar + "part" + reset + ".")
|
|
|
+ return
|
|
|
+ if not homeadmin and not self.channels[command.split()[1]].is_owner(event.source.nick) and not self.channels[command.split()[1]].is_admin(event.source.nick) and not self.channels[command.split()[1]].is_oper(event.source.nick): # 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 + ".")
|
|
|
+ return
|
|
|
+ try:
|
|
|
+ connection.part(command.split()[1], command.split(maxsplit=2)[2])
|
|
|
+ except:
|
|
|
+ connection.part(command.split()[1], event.source.nick)
|
|
|
+
|
|
|
elif command.split()[0] == "die":
|
|
|
if not self.channels[self.homechannel].is_owner(event.source.nick) and not self.channels[self.homechannel].is_admin(event.source.nick):
|
|
|
connection.privmsg(replyto, "Denied, you need to have admin (super operator) status or higher in " + red + self.homechannel + reset + ".")
|