tBKwtWS před 7 roky
rodič
revize
7c1b9cd38b
2 změnil soubory, kde provedl 8 přidání a 4 odebrání
  1. 1 0
      irc/commands/common.py
  2. 7 4
      irc/commands/games.py

+ 1 - 0
irc/commands/common.py

@@ -183,6 +183,7 @@ class GameHelpers():
         kickkarma = ((given * received) / total_xp) / 2
         xpkarma = xp / 25
         coinkarma = (coin - coin_given / (xp_spent + 1)) / 99
+        print(karma_correction)
         karma = float(joinkarma) + float(chatkarma) - float(kickkarma) + float(xpkarma) - float(coinkarma) + float(karma_correction)
         if xp < 0:
             xp = 0

+ 7 - 4
irc/commands/games.py

@@ -217,10 +217,13 @@ def do_command(self, connection, event):
                 connection.privmsg(replyto, "You already have your own coin. For help type " + blue + self.helpchar + "givecoin" + reset + ".")
                 return
             elif len(command.split()) == 3:
-                if command.split()[2] < 0:
-                    connection.privmsg(replyto, "You clever abuser! The " + red + self.cmdchar + bold + "give" + bold + "coin" + reset + " command is not designed for robbing. There will be consequences...")
-                    self.db.run("UPDATE users SET coin=coin-3, karma_correction=karma_correction-0.5 WHERE name=%s", (event.source.nick))
-                    return
+                try:
+                    if str(command.split()[2]) < 0:
+                        connection.privmsg(replyto, "You clever abuser! The " + red + self.cmdchar + bold + "give" + bold + "coin" + reset + " command is not designed for robbing. There will be consequences...")
+                        self.db.run("UPDATE users SET coin=coin-3, karma_correction=karma_correction-0.5 WHERE name=%s", (event.source.nick))
+                        return
+                except TypeError:
+                    connection.privmsg(replyto, "Invalid amount. For help type " + blue + self.helpchar + "givecoin" + reset + ".")
             elif not event.target == connection.get_nickname():
                 if not command.split()[1] in self.channels[event.target].users():
                     connection.privmsg(replyto, red + trigger.split()[1] + reset + " is not present.")