|
|
@@ -1,4 +1,4 @@
|
|
|
-from commands.common import CommandHelpers as CH
|
|
|
+from commands.common import CommandHelpers as CH, StatisticsHelpers
|
|
|
|
|
|
bold = "\x02"
|
|
|
italic = "\x1D"
|
|
|
@@ -94,7 +94,7 @@ def do_command(self, connection, event):
|
|
|
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.
|
|
|
- userstat = self.db.all("SELECT given, received FROM kicks WHERE channel_network='" + self.network + "' AND LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")
|
|
|
+ userstat = self.db.all("SELECT given, received FROM kicks WHERE LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")
|
|
|
kicksgiven = 0
|
|
|
kicksreceived = 0
|
|
|
for record in userstat:
|
|
|
@@ -104,18 +104,27 @@ 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":
|
|
|
+ elif command.split()[0] == "messages" or command.split()[0] == "actions" or command.split()[0] == "notices":
|
|
|
+ userstat = self.db.all("SELECT " + command.split()[0] + ", " + command.split()[0] + "_words, " + command.split()[0] + "_characters FROM messages WHERE LOWER(\"user\")=LOWER('" + user + "') AND user_network='" + self.network + "'")
|
|
|
+ if not userstat:
|
|
|
+ if command.split()[0] == "messages":
|
|
|
+ connection.action(replyto, "has no record of " + red + user + reset + " speaking.")
|
|
|
+ return
|
|
|
+ if command.split()[0] == "actions":
|
|
|
+ connection.action(replyto, "has no record of " + red + user + reset + " acting.")
|
|
|
+ return
|
|
|
+ if command.split()[0] == "notices":
|
|
|
+ connection.action(replyto, "has not noticed " + red + user + reset + ".")
|
|
|
+ return
|
|
|
+ messages, words, characters = StatisticsHelpers.add_message_stats(userstat)
|
|
|
+ message = "Totals of " + red + user + " " + green + str(messages) + reset + " messages, " + green + str(words) + reset + " words, " + green + str(characters) + reset + " characters."
|
|
|
if channel: # User and channel.
|
|
|
- pass
|
|
|
- else: # User only.
|
|
|
- pass
|
|
|
-
|
|
|
-# userstatfields = ()
|
|
|
-# userchannelstatfields = ()
|
|
|
-# channelstatfields = ()
|
|
|
-# userstatvalues = ()
|
|
|
-# userchannelstatvalues = ()
|
|
|
-# channelstatvalues = ()
|
|
|
-# userstatparameters = ()
|
|
|
-# userchannelstatparameters = ()
|
|
|
-# channelstatparameters = ()
|
|
|
+ userchanstat = self.db.one("SELECT " + command.split()[0] + ", " + command.split()[0] + "_words, " + command.split()[0] + "_characters FROM messages WHERE lower(channel)=lower('" + channel + "') AND channel_network='" + self.network + "' AND lower(\"user\")=lower('" + user + "') AND user_network='" + self.network + "'")
|
|
|
+ chanstat = self.db.all("SELECT " + command.split()[0] + ", " + command.split()[0] + "_words, " + command.split()[0] + "_characters FROM messages WHERE lower(channel)=lower('" + channel + "') AND channel_network='" + self.network + "'")
|
|
|
+ if userchanstat:
|
|
|
+ message += " " + red + user + reset + " in " + red + channel + " " + green + str(userchanstat[0]) + reset + " mssgs, " + green + str(userchanstat[1]) + reset + " words, " + green + str(userchanstat[2]) + reset + " chars."
|
|
|
+ if chanstat:
|
|
|
+ messages, words, characters = StatisticsHelpers.add_message_stats(chanstat)
|
|
|
+ message += " Total in " + red + channel + " " + green + str(messages) + reset + " msg, " + green + str(words) + reset + " wrd, " + green + str(characters) + reset + " chr."
|
|
|
+
|
|
|
+ connection.privmsg(replyto, message)
|