.top function
This commit is contained in:
parent
ef2abe3622
commit
6b9fd384ec
|
@ -143,10 +143,26 @@ class StockPlay(ModuleBase):
|
||||||
self.do_trade(data)
|
self.do_trade(data)
|
||||||
elif action == "portreport":
|
elif action == "portreport":
|
||||||
self.do_report(*data)
|
self.do_report(*data)
|
||||||
|
elif action == "topten":
|
||||||
|
self.do_topten(*data)
|
||||||
except Exception:
|
except Exception:
|
||||||
traceback.print_exc()
|
traceback.print_exc()
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
def do_topten(self, nick, replyto):
|
||||||
|
"""
|
||||||
|
Do lookup of highest valued portfolios
|
||||||
|
"""
|
||||||
|
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
|
||||||
|
ON h1.nick = h2.nick AND h1.day = h2.MaxDate
|
||||||
|
ORDER BY total DESC""").fetchall(), start=1):
|
||||||
|
|
||||||
|
self.bot.act_PRIVMSG(replyto, "{}: {} with total: ~{}".format(num, row.nick, row.total))
|
||||||
|
|
||||||
def do_trade(self, trade):
|
def do_trade(self, trade):
|
||||||
"""
|
"""
|
||||||
Perform a queued trade
|
Perform a queued trade
|
||||||
|
@ -452,6 +468,17 @@ class StockPlay(ModuleBase):
|
||||||
else message.args[0],
|
else message.args[0],
|
||||||
full)))
|
full)))
|
||||||
|
|
||||||
|
@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
|
||||||
|
"""
|
||||||
|
self.asyncq.put(("topten", (message.prefix.nick,
|
||||||
|
message.prefix.nick if not message.args[0].startswith("#")
|
||||||
|
else message.args[0])))
|
||||||
|
|
||||||
def check_nick(self, nick):
|
def check_nick(self, nick):
|
||||||
"""
|
"""
|
||||||
Set up a user's account by setting the initial balance
|
Set up a user's account by setting the initial balance
|
||||||
|
|
Loading…
Reference in New Issue