浏览代码

minor fixes

tBKwtWS 7 年之前
父节点
当前提交
14dbf946a3
共有 5 个文件被更改,包括 17 次插入9 次删除
  1. 3 1
      irc/bot.py
  2. 6 3
      irc/commands/common.py
  3. 5 2
      irc/commands/games.py
  4. 2 2
      irc/commands/public.py
  5. 1 1
      irc/commands/statistics.py

+ 3 - 1
irc/bot.py

@@ -141,7 +141,9 @@ class PyRot(irc.bot.SingleServerIRCBot):
         commands.statistics.do_command(self, connection, event)
         commands.games.do_command(self, connection, event)
         try:
-            if event.source.nick == "NickServ":
+            if event.source.nick == connection.get_nickname():
+                return
+            elif event.source.nick == "NickServ":
                 if event.arguments[0].startswith("This nickname is registered"):
                     connection.privmsg("NickServ", "identify " + connection.nickname + " " + self.password) # Identify with NickServ.
                 if event.arguments[0] == "You are already identified.":

+ 6 - 3
irc/commands/common.py

@@ -205,12 +205,15 @@ class GameHelpers():
         for record in result:
             if not record[column] <= threshold:
                 level, xp, xpspent, karma, coin, coinspent, coingiven, apspent = GameHelpers.get_info(self, record[0])
+                ap = xp + xpspent
+                if ap < 0:
+                    ap = 0
                 if sort == "level":
-                    message += red + str(record[0]) + reset + " [" + blue + "L " + green + str(level) + reset + ", X " + grey + str(xpspent) + "/" + green + str(int(xp)) + reset + ", A " + str(int(xp - float(apspent))) + ", C " + green + str(coin) + reset + ", K " + green + str(round(karma, 2)) + reset + "], "
+                    message += red + str(record[0]) + reset + " [" + blue + "L " + green + str(level) + reset + ", X " + grey + str(xpspent) + "/" + green + str(int(xp + xpspent)) + reset + ", A " + str(int(ap - float(apspent))) + ", C " + green + str(coin) + reset + ", K " + green + str(round(karma, 2)) + reset + "], "
                 if sort == "xp_spent":
-                    message += red + str(record[0]) + reset + " [L " + green + str(level) + reset + ", " + blue + "X " + grey + str(xpspent) + "/" + green + str(int(xp)) + reset + ", A " + str(int(xp - float(apspent))) + ", C " + green + str(coin) + reset + ", K " + green + str(round(karma, 2)) + reset + "], "
+                    message += red + str(record[0]) + reset + " [L " + green + str(level) + reset + ", " + blue + "X " + grey + str(xpspent) + "/" + green + str(int(xp + xpspent)) + reset + ", A " + str(int(ap - float(apspent))) + ", C " + green + str(coin) + reset + ", K " + green + str(round(karma, 2)) + reset + "], "
                 if sort == "coin":
-                    message += red + str(record[0]) + reset + " [L " + green + str(level) + reset + ", X " + grey + str(xpspent) + "/" + green + str(int(xp)) + reset + ", " + reset + "A " + str(int(xp - float(apspent))) + ", " + blue + "C " + green + str(coin) + reset + ", K " + green + str(round(karma, 2)) + reset + "], "
+                    message += red + str(record[0]) + reset + " [L " + green + str(level) + reset + ", X " + grey + str(xpspent) + "/" + green + str(int(xp + xpspent)) + reset + ", " + reset + "A " + str(int(ap - float(apspent))) + ", " + blue + "C " + green + str(coin) + reset + ", K " + green + str(round(karma, 2)) + reset + "], "
         return message[:-2]
 
 class StatisticsHelpers():

+ 5 - 2
irc/commands/games.py

@@ -162,7 +162,10 @@ def do_command(self, connection, event):
                 return
              
             level, xp, xpspent, karma, coin, coinspent, coingiven, apspent = GameHelpers.get_info(self, user)
-            connection.privmsg(replyto, message + "Level: " + str(level) + grey + ", " + reset + "XP: " + grey + str(xpspent) + "/" + reset + str(round(xp, 4)) + grey + ", " + reset + "AP: " + str(int(xp - float(apspent))) + grey + ", " + reset + "coin: " + str(coin) + grey + "[S " + str(coinspent) + ", G " + str(coingiven) + "], " + reset + "karma: " + str(round(karma, 4)))
+            ap = xp + xpspent
+            if ap < 0:
+                ap = 0
+            connection.privmsg(replyto, message + "Level: " + str(level) + grey + ", " + reset + "XP: " + grey + str(xpspent) + "/" + reset + str(round(xp + xpspent, 4)) + grey + ", " + reset + "AP: " + str(int(ap - float(apspent))) + grey + ", " + reset + "coin: " + str(coin) + grey + "[S " + str(coinspent) + ", G " + str(coingiven) + "], " + reset + "karma: " + str(round(karma, 4)))
     
     elif command.split()[0] == "levelup":
         if cmdtype == "help":    #Display help text.
@@ -266,7 +269,7 @@ def do_command(self, connection, event):
             connection.privmsg(replyto, "XP is earned by using IRC and playing the game in channels with " + red + connection.get_nickname() + reset + ". Ask any operator in " + red + self.homechannel + reset + " to add a channel. AP is expended for every action you take in the game.")
     elif command.split()[0] == "coin":
         if cmdtype == "help":    #Display help text.
-            connection.privmsg(replyto, "Coin is earned when certain events occur, for instance when a player expands XP. Coin is used to buy items and classes. To give a player coin use " + blue + self.cmdchar + "givecoin" + reset + ". Coin affects karma.")
+            connection.privmsg(replyto, "Coin is earned when certain events occur, for instance when a player expends XP. Coin is used to buy items and classes. To give a player coin use " + blue + self.cmdchar + "givecoin" + reset + ". Coin affects karma.")
     elif command.split()[0] == "karma":
         if cmdtype == "help":    #Display help text.
             connection.privmsg(replyto, "Karma is a secret formula, based upon on yuor IRC events and how you play the game. It does not increase like XP. Some events, skills and items are karma based.")

+ 2 - 2
irc/commands/public.py

@@ -39,9 +39,9 @@ def do_command(self, connection, event):
             connection.privmsg(replyto, "Displays a list of commands.")
         elif cmdtype == "cmd":
             if not event.target == connection.get_nickname() and not self.db.one("SELECT join_greeting FROM channels WHERE name='" + event.target + "' AND network='" + self.network + "'"):
-                connection.privmsg(replyto, grey + "Commands: " + CH.ccc(self, "cmd") + CH.ccc(self, "help") + CH.ccc(self, "away")[:-2] + ".")
+                connection.privmsg(replyto, grey + "Public: " + CH.ccc(self, "cmd") + CH.ccc(self, "help") + CH.ccc(self, "away")[:-2] + ".")
             else:
-                connection.privmsg(replyto, grey + "Commands: " + CH.ccc(self, "cmd") + CH.ccc(self, "help") + CH.ccc(self, "away") + CH.ccc(self, "stopgreet")[:-2] + ".")
+                connection.privmsg(replyto, grey + "Public: " + CH.ccc(self, "cmd") + CH.ccc(self, "help") + CH.ccc(self, "away") + CH.ccc(self, "stopgreet")[:-2] + ".")
     
     elif command == "help":
         if cmdtype == "help":    #Display help text.

+ 1 - 1
irc/commands/statistics.py

@@ -28,7 +28,7 @@ def do_command(self, connection, event):
 
     if command == "cmd" or command == "cmds" or command == "commands":
         if cmdtype == "cmd":
-            connection.privmsg(replyto, grey + "Statistics commands: " + CH.ccc(self, "seen") + CH.ccc(self, "joins") + CH.ccc(self, "kicks") + CH.ccc(self, "messages") + CH.ccc(self, "actions") + CH.ccc(self, "notices")[:-2] + ".")
+            connection.privmsg(replyto, grey + "Statistics: " + CH.ccc(self, "seen") + CH.ccc(self, "joins") + CH.ccc(self, "kicks") + CH.ccc(self, "messages") + CH.ccc(self, "actions") + CH.ccc(self, "notices")[:-2] + ".")
     
     
     elif command.split()[0] == "joins" or command.split()[0] == "kicks" or command.split()[0] == "messages" or command.split()[0] == "actions" or command.split()[0] == "notices":