From ef9e95846787de383bacb83db69289e9994ca20a Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Mon, 27 Dec 2021 19:02:31 +0000 Subject: [PATCH] Be smarter about printing out information to IRC --- handler/irc.py | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/handler/irc.py b/handler/irc.py index b282ea3..f446dd8 100644 --- a/handler/irc.py +++ b/handler/irc.py @@ -80,7 +80,23 @@ class IRCBot(irc.IRCClient): elif cmd == "trades" and host in self.admins: trades = self.agora.dashboard() - self.msg(channel, dumps(trades)) + for trade_id in trades: + fmt = ( + f"{trade_id}: {trades[trade_id]['buyer']} " + f"{trades[trade_id]['amount']}{trades[trade_id]['currency']} {trades[trade_id]['amount_xmr']}XMR" + ) + self.msg(channel, fmt) + + elif cmd == "create" and host in self.admins and len(spl) == 3: + posted = self.agora.create_ad(spl[1], spl[2]) + self.msg(channel, dumps(posted)) + + elif cmd == "messages" and host in self.admins and len(spl) == 1: + messages = self.agora.get_all_messages() + for message_id in messages: + for message in messages[message_id]: + self.msg(channel, f"{message_id}: {message}") + # self.msg(channel, dumps(messages)) def stopcall(self, call): call.stop()