浏览代码

statistics no longer activated on games

tBKwtWS 7 年之前
父节点
当前提交
1068330db7
共有 3 个文件被更改,包括 32 次插入52 次删除
  1. 1 1
      .eric6project/pyRot.e4q
  2. 3 3
      .eric6project/pyRot.e6t
  3. 28 48
      commands/statistics.py

+ 1 - 1
.eric6project/pyRot.e4q

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE UserProject SYSTEM "UserProject-4.0.dtd">
 <!-- eric6 user project file for project pyRot -->
-<!-- Saved: 2018-01-28, 18:31:01 -->
+<!-- Saved: 2018-01-30, 00:44:45 -->
 <!-- Copyright (C) 2018 tBKwtWS,  -->
 <UserProject version="4.0"/>

+ 3 - 3
.eric6project/pyRot.e6t

@@ -1,13 +1,13 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <!DOCTYPE Tasks SYSTEM "Tasks-6.0.dtd">
 <!-- eric6 tasks file for project pyRot -->
-<!-- Saved: 2018-01-29, 02:50:52 -->
+<!-- Saved: 2018-01-30, 17:07:04 -->
 <Tasks version="6.0">
   <ProjectScanFilter></ProjectScanFilter>
-  <Task priority="1" completed="False" type="2" uid="{4cfd7321-6af7-451f-8dd6-5377b0147cd6}">
+  <Task priority="1" completed="False" type="2" uid="{6fba5483-7aac-4f85-85f1-bcf11fb6f5c0}">
     <Summary>WARNING: &quot; + str(message))</Summary>
     <Description></Description>
-    <Created>2018-01-29, 02:50:49</Created>
+    <Created>2018-01-30, 17:07:01</Created>
     <Resource>
       <Filename>common/log.py</Filename>
       <Linenumber>8</Linenumber>

+ 28 - 48
commands/statistics.py

@@ -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