From 2533c5872a3212bd6ecf390149e0ddb6ed2e02cb Mon Sep 17 00:00:00 2001 From: Mike Edmister Date: Thu, 25 Apr 2019 10:27:55 -0400 Subject: [PATCH] lowered priority of .top, fixed query, removed @protected --- pyircbot/irccore.py | 4 ++-- pyircbot/modules/StockPlay.py | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/pyircbot/irccore.py b/pyircbot/irccore.py index 3c8797d..7d80165 100644 --- a/pyircbot/irccore.py +++ b/pyircbot/irccore.py @@ -346,14 +346,14 @@ class IRCCore(object): :type channel: str""" self.sendRaw("JOIN %s" % channel, priority=3) - def act_PRIVMSG(self, towho, message): + def act_PRIVMSG(self, towho, message, priority=None): """Use the `/msg` command :param towho: the target #channel or user's name :type towho: str :param message: the message to send :type message: str""" - self.sendRaw("PRIVMSG %s :%s" % (towho, message)) + self.sendRaw("PRIVMSG %s :%s" % (towho, message), priority=priority) def act_MODE(self, channel, mode, extra=None): """Use the `/mode` command diff --git a/pyircbot/modules/StockPlay.py b/pyircbot/modules/StockPlay.py index 40ff8c6..a1fa274 100644 --- a/pyircbot/modules/StockPlay.py +++ b/pyircbot/modules/StockPlay.py @@ -156,12 +156,13 @@ class StockPlay(ModuleBase): self.log.warning("{} wants top 10 sent to {}".format(nick, replyto)) with closing(self.sql.getCursor()) as c: - for num, row in enumerate(c.execute("""SELECT h1.nick as nick, h1.total as total FROM stockplay_balance_history h1 - INNER JOIN (SELECT nick, max(day) as MaxDate FROM stockplay_balance_history GROUP BY nick) h2 + for num, row in enumerate(c.execute("""SELECT h1.nick as nick, CAST(h1.cents as INTEGER) as cents FROM stockplay_balance_history h1 + INNER JOIN (SELECT nick, max(day) as MaxDate FROM stockplay_balance_history WHERE nick != ? GROUP BY nick) h2 ON h1.nick = h2.nick AND h1.day = h2.MaxDate - ORDER BY total DESC LIMIT 10""").fetchall(), start=1): - - self.bot.act_PRIVMSG(replyto, "{}: {} with total: ~{}".format(num, row.nick, row.total)) + ORDER BY cents DESC LIMIT 10""", (DUSTACCT, )).fetchall(), start=1): + total = Decimal(row.cents) / 100 + self.bot.act_PRIVMSG(replyto, + "{}: {} with total: ~{}".format(num, row.nick, total), priority=5) def do_trade(self, trade): """ @@ -470,7 +471,6 @@ class StockPlay(ModuleBase): @info("top", "show top portfolios", cmds=["top", "top10"]) @command("top", "top10", allow_private=True) - @protected() def cmd_top(self, message, command): """ Top 10 report command