Bläddra i källkod

added channelonly result to statistics.

tBKwtWS 7 år sedan
förälder
incheckning
f7b784be3b
1 ändrade filer med 8 tillägg och 2 borttagningar
  1. 8 2
      commands/statistics.py

+ 8 - 2
commands/statistics.py

@@ -37,6 +37,7 @@ def do_command(self, connection, event):
             # Parse user input
             user = event.source.nick
             channel = None
+            channelonly= False
             if not connection.get_nickname() == event.target:   # Channel message.
                 channel = event.target
             if len(command.split()) == 1:    # Command contains only !joins.
@@ -44,6 +45,7 @@ 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
                 else:
                     user = command.split()[1]
             elif len(command.split()) == 3: # Command has two arguments.
@@ -68,7 +70,9 @@ def do_command(self, connection, event):
                     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 userchannelstat == "None":
                         userchannelstat = "0"
-                    if userstat == "0": # No user joins on record.
+                    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 + ".")
                     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.")
@@ -78,7 +82,9 @@ def do_command(self, connection, event):
                     except:
                         givenkicks = 0
                         receivedkicks = 0
-                    if givenkicks == 0 and receivedkicks == 0:  # No kicks on record.
+                    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 + ".")
                     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 + "'")