|
|
@@ -14,15 +14,11 @@ def do_command(self, connection, event):
|
|
|
cmdtype, trigger, command, replyto = CH.disect_command(self, event)
|
|
|
if not command: # Do nothing if there is no command.
|
|
|
return
|
|
|
- if not self.db.one("SELECT games FROM channels WHERE name='" + event.target + "' AND network='" + self.network + "'") and not event.target == connection.get_nickname():
|
|
|
+ if not self.db.one("SELECT statistics_commands FROM channels WHERE name='" + event.target + "' AND network='" + self.network + "'") and not event.target == connection.get_nickname():
|
|
|
return # Do noting if the games channel function is off and it's a channel message.
|
|
|
|
|
|
if command == "cmd" or command == "commands":
|
|
|
- if cmdtype == "help": #Display help text.
|
|
|
- if len(command.split()) is not 1:
|
|
|
- return
|
|
|
- connection.privmsg(replyto, "Displays a list of commands.")
|
|
|
- elif cmdtype == "cmd":
|
|
|
+ if cmdtype == "cmd":
|
|
|
connection.privmsg(replyto, grey + "Statistics commands: " + CH.ccc(self, "joins") + CH.ccc(self, "kicks") + CH.ccc(self, "messages")[:-2] + ".")
|
|
|
|
|
|
|
|
|
@@ -45,7 +41,8 @@ def do_command(self, connection, event):
|
|
|
elif len(command.split()) == 2: # Command has one argument.
|
|
|
if command.split()[1] in self.channels:
|
|
|
channel = command.split()[1]
|
|
|
- channelonly = True
|
|
|
+ if connection.get_nickname() == event.target: # Private message.
|
|
|
+ channelonly = True
|
|
|
else:
|
|
|
user = command.split()[1]
|
|
|
elif len(command.split()) == 3: # Command has two arguments.
|
|
|
@@ -63,40 +60,40 @@ def do_command(self, connection, event):
|
|
|
connection.privmsg(replyto, "To many arguments. For help type " + blue + self.helpchar + "joins" + reset + ".")
|
|
|
return
|
|
|
|
|
|
- if channel: # User and channel.
|
|
|
- if command.split()[0] == "joins":
|
|
|
- userstat = str(sum(self.db.all("SELECT " + command.split()[0].lower() + " FROM " + command.split()[0].lower() + " WHERE channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")))
|
|
|
- userchannelstat = str(self.db.one("SELECT " + command.split()[0].lower() + " FROM " + command.split()[0].lower() + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'"))
|
|
|
- channelstat = str(sum(self.db.all("SELECT " + command.split()[0].lower() + " FROM " + command.split()[0].lower() + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "' AND user_network='" + self.network + "'")))
|
|
|
+ if command.split()[0] == "joins":
|
|
|
+ if channel: # User and channel.
|
|
|
+ userstat = str(sum(self.db.all("SELECT " + command.split()[0] + " FROM " + command.split()[0] + " WHERE channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")))
|
|
|
+ userchannelstat = str(self.db.one("SELECT " + command.split()[0] + " FROM " + command.split()[0] + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'"))
|
|
|
+ channelstat = str(sum(self.db.all("SELECT " + command.split()[0] + " FROM " + command.split()[0] + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "' AND user_network='" + self.network + "'")))
|
|
|
if userchannelstat == "None":
|
|
|
userchannelstat = "0"
|
|
|
if channelonly:
|
|
|
connection.privmsg(replyto, red + channel + reset + " has " + green + channelstat + reset + " " + command.split()[0] + reset + " in total.")
|
|
|
elif userstat == "0" and not channelonly: # No user joins on record.
|
|
|
- connection.action(replyto, "has no record of any joins for " + red + user + reset + ".")
|
|
|
+ connection.action(replyto, "has no record of any joins by " + red + user + reset + " in " + red + channel + reset + ".")
|
|
|
else: # User joins on record.
|
|
|
connection.privmsg(replyto, red + user + reset + " has " + green + userstat + reset + " " + command.split()[0] + ". Of which " + green + userchannelstat + reset + " have been in " + red + channel + reset + ", that has " + green + channelstat + reset + " " + command.split()[0] + reset + " in total.")
|
|
|
- elif command.split()[0] == "kicks":
|
|
|
+ else: # Only user.
|
|
|
+ userstat = str(sum(self.db.all("SELECT " + command.split()[0] + " FROM " + command.split()[0] + " WHERE channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")))
|
|
|
+ if userstat == "0": # No statistics on user.
|
|
|
+ connection.action(replyto, "has no record of any joins by " + red + user + reset + ".")
|
|
|
+ else: # Got statistics on user.
|
|
|
+ connection.privmsg(replyto, red + user + reset + " has " + green + userstat + reset + " " + command.split()[0] + " in channels I monitor.")
|
|
|
+ elif command.split()[0] == "kicks":
|
|
|
+ if channel: # User and channel.
|
|
|
try:
|
|
|
- givenkicks, receivedkicks = self.db.one("SELECT given, received FROM " + command.split()[0].lower() + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")
|
|
|
+ givenkicks, receivedkicks = self.db.one("SELECT given, received FROM " + command.split()[0] + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")
|
|
|
except:
|
|
|
givenkicks = 0
|
|
|
receivedkicks = 0
|
|
|
if channelonly:
|
|
|
connection.privmsg(replyto, red + channel + reset + " has " + green + channelstat + reset + " " + command.split()[0] + reset + " in total.")
|
|
|
elif givenkicks == 0: # No kicks on record.
|
|
|
- connection.action(replyto, "has no record of any kicks for " + red + user + reset + ".")
|
|
|
+ connection.action(replyto, "has no record of any kicks for " + red + user + reset + " in " + red + channel + reset + ".")
|
|
|
else: # Kciks on record.
|
|
|
- channelkicks = self.db.all("SELECT given FROM " + command.split()[0].lower() + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "'")
|
|
|
+ channelkicks = self.db.all("SELECT given FROM " + command.split()[0] + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "'")
|
|
|
connection.privmsg(replyto, red + user + reset + " has kicked " + green + str(givenkicks) + reset + " and been kicked " + green + str(receivedkicks) + reset + " times in " + red + channel + reset + ", where were " + green + str(sum(channelkicks)) + reset + " kicks in total.")
|
|
|
- else: # Only user.
|
|
|
- if command.split()[0] == "joins":
|
|
|
- userstat = str(sum(self.db.all("SELECT " + command.split()[0] + " FROM " + command.split()[0] + " WHERE channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")))
|
|
|
- if userstat == "0": # No statistics on user.
|
|
|
- connection.action(replyto, "has no record of any " + command.split()[0] + " for " + red + user + reset + ".")
|
|
|
- else: # Got statistics on user.
|
|
|
- connection.privmsg(replyto, red + user + reset + " has " + green + userstat + reset + " " + command.split()[0] + " in channels I monitor.")
|
|
|
- elif command.split()[0] == "kicks":
|
|
|
+ else: # Only user.
|
|
|
userstat = self.db.all("SELECT given, received FROM kicks WHERE channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")
|
|
|
kicksgiven = 0
|
|
|
kicksreceived = 0
|
|
|
@@ -107,6 +104,12 @@ def do_command(self, connection, event):
|
|
|
connection.action(replyto, red + user + reset + " has no record of any kicks for " + red + user + reset + " in " + red + channel + reset + ".")
|
|
|
else:
|
|
|
connection.privmsg(replyto, red + user + reset + " has given " + green + str(kicksgiven) + reset + " and received " + green + str(kicksreceived) + reset + " kicks")
|
|
|
+ elif command.split()[0] == "messages":
|
|
|
+ if channel: # User and channel.
|
|
|
+ pass
|
|
|
+ else: # User only.
|
|
|
+ pass
|
|
|
+
|
|
|
# userstatfields = ()
|
|
|
# userchannelstatfields = ()
|
|
|
# channelstatfields = ()
|
|
|
@@ -116,26 +119,3 @@ def do_command(self, connection, event):
|
|
|
# userstatparameters = ()
|
|
|
# userchannelstatparameters = ()
|
|
|
# channelstatparameters = ()
|
|
|
-
|
|
|
-
|
|
|
-# try:
|
|
|
-# if user and channel:
|
|
|
-#
|
|
|
-# return
|
|
|
-# except:
|
|
|
-# pass
|
|
|
-# try:
|
|
|
-#
|
|
|
-# return
|
|
|
-# except:
|
|
|
-# pass
|
|
|
-# try:
|
|
|
-# if channel: # This situation should not occur anymore.
|
|
|
-# channelstat = str(sum(self.db.all("SELECT " + command.split()[0] + " FROM " + command.split()[0] + " WHERE LOWER(channel)=LOWER('" + channel + "') AND channel_network='" + self.network + "' AND user_network='" + self.network + "'")))
|
|
|
-# if command.split()[0] == "joins":
|
|
|
-# connection.privmsg(replyto, red + channel + reset + " has been " + command.split()[0][:-1] + "ed " + green + channelstat + reset + " times.")
|
|
|
-# elif command.split()[0] == "kicks":
|
|
|
-# connection.privmsg(replyto, "There have been " + green + channelstat + reset + " kicks in " + red + command.split()[0] + reset + ".")
|
|
|
-# return
|
|
|
-# except:
|
|
|
-# pass
|