From 6743bd510680851242aa29fa67aa8fe7a631c6f5 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Tue, 28 Dec 2021 23:57:25 +0000 Subject: [PATCH] Add commands to manage references --- handler/commands.py | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/handler/commands.py b/handler/commands.py index b1a924a..1730bcd 100644 --- a/handler/commands.py +++ b/handler/commands.py @@ -155,3 +155,37 @@ class IRCCommands(object): full_msg = " ".join(spl[2:]) rtrn = agora.agora.contact_message_post(spl[1], full_msg) msg(f"Sent {full_msg} to {spl[1]}: {rtrn}") + + class refs(object): + name = "refs" + authed = True + + @staticmethod + def run(cmd, spl, length, authed, msg, agora, revolut, tx): + msg(f"References: {', '.join(tx.get_refs())}") + + class ref(object): + name = "ref" + authed = True + + @staticmethod + def run(cmd, spl, length, authed, msg, agora, revolut, tx): + if length == 2: + ref_data = tx.get_ref(spl[1]) + if not ref_data: + msg("No such reference: {spl[1]}") + msg(f"{spl[1]}: {dumps(ref_data)}") + + class delete(object): + name = "del" + authed = True + + @staticmethod + def run(cmd, spl, length, authed, msg, agora, revolut, tx): + if length == 2: + ref_data = tx.get_ref(spl[1]) + if not ref_data: + msg(f"No such reference: {spl[1]}") + return + tx.del_ref(spl[1]) + msg(f"Deleted reference: {spl[1]}")