Quellcode durchsuchen

catch protectees key match

tBKwtWS vor 7 Jahren
Ursprung
Commit
93087dad24
4 geänderte Dateien mit 15 neuen und 10 gelöschten Zeilen
  1. 2 2
      irc/commands/common.py
  2. 1 2
      irc/common/queries.py
  3. 7 4
      irc/events/on_mode.py
  4. 5 2
      webgui/stats/views.py

+ 2 - 2
irc/commands/common.py

@@ -165,10 +165,10 @@ class GameHelpers():
         
         chatxp = messages + (messages_words / 4) + (messages_characters / 10) + ((actions + (actions_words / 4) + (actions_characters / 10)) * 2) + ((notices + (notices_words / 4) + (notices_characters / 10)) / 2)
         kickxp = given * received
-        total_xp = ((joins + kickxp + chatxp) / 120) + float(coin_spent + ap_spent / 4) - (level * 5) 
+        total_xp = ((joins + kickxp + chatxp) / 120) + float(coin_spent + ap_spent / 8) - (level * 5) 
         
         xp = total_xp - xp_spent
-        ap = total_xp + xp - float(ap_spent)
+        ap = total_xp - float(ap_spent)
         total_messages = messages + actions + notices
         total_words = messages_words + actions_words + notices_words
         total_characters = messages_characters + actions_characters + notices_characters

+ 1 - 2
irc/common/queries.py

@@ -1,7 +1,6 @@
 def create_ifnot_onrecord(self, table, name):
     record = self.db.one("SELECT name, network FROM " + table + " WHERE LOWER(name)=LOWER(%s) AND LOWER(network)=LOWER(%s)", (name, self.network, ))
     
-    
     if record:  # On record.
         # Correct capitalisation of network name, if needed.
         if not self.network == record[1]:
@@ -12,5 +11,5 @@ def create_ifnot_onrecord(self, table, name):
             self.db.run("UPDATE " + table + " SET name=%s WHERE LOWER(name)=LOWER(%s) AND network=%s", (name, name, self.network, ))
     
     # Create record.
-    else:
+    else:   # Not on record.
         self.db.run("INSERT INTO " + table + " (name, network) VALUES (%s, %s)", (name, self.network, ))

+ 7 - 4
irc/events/on_mode.py

@@ -47,10 +47,13 @@ def process_event(self, connection, event):
                 self.db.run("UPDATE channels SET key=NULL WHERE name='" + event.target + "' AND network='" + self.network + "'")
         
         # Unban if bot is banned from home channel
-        if mode[1] == "b" and fnmatch.fnmatch(self.protectees[connection.get_nickname()]['ident'], mode[2]) and mode[0] == "+" and event.target == self.homechannel:
-            connection.privmsg("ChanServ", "UNBAN")
-            do_everything_to.unban(connection, event.target, connection.get_nickname(), mode[2])
-            connection.mode(event.target, "-b " + mode[2])
+        try:
+            if mode[1] == "b" and fnmatch.fnmatch(self.protectees[connection.get_nickname()]['ident'], mode[2]) and mode[0] == "+" and event.target == self.homechannel:
+                connection.privmsg("ChanServ", "UNBAN")
+                do_everything_to.unban(connection, event.target, connection.get_nickname(), mode[2])
+                connection.mode(event.target, "-b " + mode[2])
+        except:
+            pass
         
         # Stop if not present in home channel.
         if not self.homechannel in self.channels:

+ 5 - 2
webgui/stats/views.py

@@ -22,6 +22,7 @@ def networks(request):
         if network.password:
             networkslist[network.name]['password'] = True
     isxpspent = False
+    iscoinspent = False
     for user in users:
         networkslist[user.network.name]['usercount'] += 1
         if user.xp_spent > 1:
@@ -85,8 +86,10 @@ def network(request, network_name):
     isxpspent = False
     for user in users:
         userslist[user.name] = {'joincount': 0, 'messagecount': 0, 'kgivencount': 0, 'kreceivedcount': 0, 'xpspent': user.xp_spent, 'coin': user.coin}
-        totalcoinspent += user.coin_spent - user.coin_given
-        totalcoingiven += user.coin_given
+        print(user.level)
+        if not user.level == 0:
+            totalcoinspent += user.coin_spent - user.coin_given
+            totalcoingiven += user.coin_given
         if not user.xp_spent == 0:
             isxpspent = True
         totalxpstats += user.xp_spent