Explorar el Código

increased verbosity

tBKwtWS hace 7 años
padre
commit
9a30391203
Se han modificado 9 ficheros con 29 adiciones y 10 borrados
  1. 1 1
      commands/common.py
  2. 12 2
      commands/statistics.py
  3. 2 1
      events/on_action.py
  4. 3 1
      events/on_join.py
  5. 3 1
      events/on_kick.py
  6. 2 1
      events/on_mode.py
  7. 1 0
      events/on_nick.py
  8. 1 1
      events/on_pubmsg.py
  9. 4 2
      rotbot.py

+ 1 - 1
commands/common.py

@@ -12,7 +12,7 @@ grey = "\x0314"
 class CommandHelpers():
     def disect_command(self, event):
         trigger = event.arguments[0]
-        command = trigger[1:]   #Command without prefix.
+        command = trigger[1:].lower()   #Command without prefix.
         
         # Determine command type.
         if trigger.startswith(self.cmdchar):

+ 12 - 2
commands/statistics.py

@@ -24,10 +24,10 @@ def do_command(self, connection, event):
                 return
             connection.privmsg(replyto, "Displays a list of commands.")
         elif cmdtype == "cmd":
-            connection.privmsg(replyto, grey + "Statistics commands: " + CH.ccc(self, "joins") + CH.ccc(self, "kicks") + CH.ccc(self, "")[:-2] + ".")
+            connection.privmsg(replyto, grey + "Statistics commands: " + CH.ccc(self, "joins") + CH.ccc(self, "kicks") + CH.ccc(self, "messages")[:-2] + ".")
     
     
-    elif command.split()[0] == "joins" or command.split()[0] == "kicks":
+    elif command.split()[0] == "joins" or command.split()[0] == "kicks" or command.split()[0] == "messages":
         if cmdtype == "help":    #Display help text.
             if len(command.split()) is not 1:
                 return
@@ -60,6 +60,16 @@ def do_command(self, connection, event):
             elif len(command.split()) < 5:  # To many arguments
                 connection.privmsg(replyto, "To many arguments. For help type " + blue + self.helpchar + "joins" + reset + ".")
                 return
+#            userstatfields = ()
+#            userchannelstatfields = ()
+#            channelstatfields = ()
+#            userstatvalues = ()
+#            userchannelstatvalues = ()
+#            channelstatvalues = ()
+#            userstatparameters = ()
+#            userchannelstatparameters = ()
+#            channelstatparameters = ()
+            
             
             try:
                 if user and channel:

+ 2 - 1
events/on_action.py

@@ -18,7 +18,8 @@ def process_event(self, connection, event):
     # Save statistic to database.
     if not self.db.one("SELECT id FROM \"users\" WHERE name='" + event.source.nick + "' AND network='" + self.network + "'"):    # Not on record.
         self.db.run("INSERT INTO \"users\" (name, network) VALUES ('" + event.source.nick + "', '" + self.network + "')")   # Create record.
-    self.db.run("UPDATE \"users\" SET actions=actions+1 WHERE name='" + event.source.nick + "' AND network='" + self.network + "'") # Increment record.
+    
+    self.db.run("UPDATE \"users\" SET actions=actions+1, actions_words=actions_words+" + str(len(event.arguments[0].split())) + ", actions_characters=actions_characters+" + str(len(event.arguments[0])) + " WHERE name='" + event.source.nick + "' AND network='" + self.network + "'") # Increment record.
     
     # Stop if channelfunction chat if off.
     if not self.db.one("SELECT chat FROM channels WHERE name='" + event.target + "' AND network='" + self.network + "'"):

+ 3 - 1
events/on_join.py

@@ -1,3 +1,4 @@
+from common import log
 from events.common import Lastact
 
 bold = "\x02"
@@ -11,6 +12,7 @@ red = "\x0304"
 grey = "\x0314"
 
 def process_event(self, connection, event):
+    log.info(event)
     
     # Update last act.
     Lastact.update(self, event.source.nick, "join", channel=event.target)
@@ -47,7 +49,7 @@ def process_event(self, connection, event):
     if joins == 1:
         message = "Welcome to " + red + event.target + reset + ", " + red + event.source.nick + reset + ". For a list of command type " + blue + self.cmdchar + "cmd" + reset + "."
     if joins == 3:
-        message = "Welcome back in " + red + event.target + reset + ", " + red + event.source.nick + reset + ". Tip: To turn of greetings, type " + blue + "!stopgreet " + reset + "."
+        message = "Welcome back in " + red + event.target + reset + ", " + red + event.source.nick + reset + ". To turn of greetings, type " + blue + "!stopgreet" + reset + "."
     if joins == 5:
         if self.channels[event.target].has_key():   # Channel has a password.
             message = "Welcome back again " + red + event.source.nick + reset + ". To automaticly join this channel type " + blue + "/ns ajoin " + reset + "ADD " + red + event.source.nick + " " + event.target + reset + italic + " password"

+ 3 - 1
events/on_kick.py

@@ -1,5 +1,5 @@
 from common.networkservices import ChanServ
-from common import userstatus, do_everything_to
+from common import userstatus, do_everything_to, log
 from events.common import Aggressiveness, Lastact
 
 bold = "\x02"
@@ -13,6 +13,8 @@ red = "\x0304"
 grey = "\x0314"
 
 def process_event(self, connection, event):
+    log.info(event)
+    
     kicker = event.source.nick
     channel = event.target
     kicked = event.arguments[0]

+ 2 - 1
events/on_mode.py

@@ -1,7 +1,7 @@
 import fnmatch
 from irc.modes import parse_channel_modes
 from common.networkservices import ChanServ
-from common import do_everything_to, userstatus
+from common import do_everything_to, userstatus, log
 from events.common import Aggressiveness, Lastact
 
 bold = "\x02"
@@ -15,6 +15,7 @@ red = "\x0304"
 grey = "\x0314"
 
 def process_event(self, connection, event):
+    log.info(event)
     
     # Update protectees.
     if event.target == self.homechannel:    # Home channel

+ 1 - 0
events/on_nick.py

@@ -3,6 +3,7 @@ from common.networkservices import NickServ
 from events.common import Lastact
 
 def process_event(self, connection, event):
+    log.info(event)
     
     # Keep preferred nick.
     if event.source.nick == connection.nickname:    # Preffered nick being changed.

+ 1 - 1
events/on_pubmsg.py

@@ -9,7 +9,7 @@ def process_event(self, connection, event):
     # Save statistic to database.
     if not self.db.one("SELECT id FROM \"users\" WHERE name='" + event.source.nick + "' AND network='" + self.network + "'"):    # Not on record.
         self.db.run("INSERT INTO \"users\" (name, network) VALUES ('" + event.source.nick + "', '" + self.network + "')")   # Create record.
-    self.db.run("UPDATE \"users\" SET messages=messages+1 WHERE name='" + event.source.nick + "' AND network='" + self.network + "'") # Increment record.
+    self.db.run("UPDATE \"users\" SET messages=messages+1, messages_words=messages_words+" + str(len(event.arguments[0].split())) + ", messages_characters=messages_characters+" + str(len(event.arguments[0])) + " WHERE name='" + event.source.nick + "' AND network='" + self.network + "'") # Increment record.
     
     if connection.get_nickname().lower() in event.arguments[0].lower() and event.source.nick is not connection.get_nickname(): # Bot's name was mentioned
         if event.arguments[0].startswith(self.cmdchar):

+ 4 - 2
rotbot.py

@@ -68,6 +68,7 @@ class PyRot(irc.bot.SingleServerIRCBot):
         events.on_mode.process_event(self, connection, event)
     
     def on_part(self, connection, event):
+        log.info(event)
         
         # Update protectees
         if event.target == self.homechannel and event.source.nick in self.protectees:    # Protectee parted home channel.
@@ -80,6 +81,7 @@ class PyRot(irc.bot.SingleServerIRCBot):
             Lastact.update(self, event.source.nick, "part", channel=event.target)
     
     def on_quit(self, connection, event):
+        log.info(event)
         
         # Update protectees
         if event.source.nick in self.protectees:    # Protectee parted home channel.
@@ -92,7 +94,7 @@ class PyRot(irc.bot.SingleServerIRCBot):
             Lastact.update(self, event.source.nick, "quit")
     
     def on_invite(self, connection, event):
-        log.info(event)
+        log.notice(event)
         if event.target == connection.get_nickname(): # Bot invited.
             connection.privmsg(self.homechannel, "Received invite to " + red + event.arguments[0] + reset + " from " + red + event.source.nick + reset + ".")
     
@@ -122,7 +124,7 @@ class PyRot(irc.bot.SingleServerIRCBot):
         # Save statistic to database.
         if not self.db.one("SELECT id FROM \"users\" WHERE name='" + event.source.nick + "' AND network='" + self.network + "'"):    # Not on record.
             self.db.run("INSERT INTO \"users\" (name, network) VALUES ('" + event.source.nick + "', '" + self.network + "')")   # Create record.
-        self.db.run("UPDATE \"users\" SET messages=messages+1 WHERE name='" + event.source.nick + "' AND network='" + self.network + "'") # Increment record.
+        self.db.run("UPDATE \"users\" SET notices=notices+1, notices_words=notices_words+" + str(len(event.arguments[0].split())) + ", notices_characters=notices_characters+" + str(len(event.arguments[0])) + " WHERE name='" + event.source.nick + "' AND network='" + self.network + "'") # Increment record.
         
         # Update last act.
         Lastact.update(self, event.source.nick, "notice", channel=event.target, lastact=event.arguments[0])