From c8e936824708e865c42d438babadeda2e4d157f8 Mon Sep 17 00:00:00 2001 From: Mark Veidemanis Date: Wed, 11 May 2022 22:08:04 +0100 Subject: [PATCH] Post IRC message on cleanup --- handler/db.py | 6 +++++- handler/sources/local.py | 4 +++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/handler/db.py b/handler/db.py index 790d941..a4d36cc 100644 --- a/handler/db.py +++ b/handler/db.py @@ -125,9 +125,13 @@ def cleanup(subclass, references): :param references: list of references to reconcile against :type references: list """ + messages = [] for tx, reference in get_ref_map().items(): if reference not in references: if get_subclass(reference) == subclass: - log.info(f"Archiving trade reference: {reference} / TX: {tx}") + logmessage = f"Archiving trade reference: {reference} / TX: {tx}" + messages.append(logmessage) + log.info(logmessage) r.rename(f"trade.{tx}.reference", f"archive.trade.{tx}.reference") r.rename(f"trade.{reference}", f"archive.trade.{reference}") + return messages diff --git a/handler/sources/local.py b/handler/sources/local.py index 086bd8d..4336909 100644 --- a/handler/sources/local.py +++ b/handler/sources/local.py @@ -171,7 +171,9 @@ class Local(util.Base): self.last_dash.remove(ref) if reference and reference not in current_trades: current_trades.append(reference) - db.cleanup(self.platform, current_trades) + messages = db.cleanup(self.platform, current_trades) + for message in messages: + self.ux.irc.sendmsg(f"{self.platform}: {message}") def got_recent_messages(self, messages, send_irc=True): """