GNU/Weeb Mailing List <[email protected]>
 help / color / mirror / Atom feed
From: Muhammad Rizki <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: Muhammad Rizki <[email protected]>,
	Alviro Iskandar Setiawan <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>
Subject: [PATCH v1 02/13] refactor(telegram): Move report_err() to the DaemonClient() class
Date: Tue,  3 Jan 2023 13:36:30 +0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

Instead of adding the report_err() function in the Bot() class, move it
to the DaemonClient() class.

Signed-off-by: Muhammad Rizki <[email protected]>
---
 daemon/telegram/mailer/listener.py | 8 +-------
 daemon/telegram/packages/client.py | 8 ++++++++
 2 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/daemon/telegram/mailer/listener.py b/daemon/telegram/mailer/listener.py
index 044de6a..8425dd4 100644
--- a/daemon/telegram/mailer/listener.py
+++ b/daemon/telegram/mailer/listener.py
@@ -61,12 +61,6 @@ class Bot():
 		self.db.ping(reconnect=True, attempts=reconnect_attempts,
 			     delay=delay_in_secs)
 
-	async def report_err(caption):
-		if not caption:
-			caption = "No lore URL"
-		exc_str = utils.catch_err()
-		self.logger.warning(exc_str)
-		await self.client.send_log_file(caption)
 
 	async def __run(self):
 		self.logger.info("Running...")
@@ -77,7 +71,7 @@ class Bot():
 		except (OperationalError, DatabaseError) as e:
 			await self.handle_db_error(e)
 		except:
-			await self.report_err(url)
+			await self.client.report_err(url)
 
 		if not self.isRunnerFixed:
 			self.isRunnerFixed = True
diff --git a/daemon/telegram/packages/client.py b/daemon/telegram/packages/client.py
index 58195b9..f543caa 100644
--- a/daemon/telegram/packages/client.py
+++ b/daemon/telegram/packages/client.py
@@ -27,6 +27,14 @@ class DaemonClient(Client):
 		self.logger = logger
 
 
+	async def report_err(self, caption):
+		if not caption:
+			caption = "No lore URL"
+		exc_str = utils.catch_err()
+		self.logger.warning(exc_str)
+		await self.send_log_file(caption)
+
+
 	@handle_flood
 	async def send_log_file(self, caption: str):
 		filename = self.logger.handlers[0].baseFilename
-- 
Muhammad Rizki


  parent reply	other threads:[~2023-01-03  6:37 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-03  6:36 [PATCH v1 00/13] Improvements, refactors, and features Muhammad Rizki
2023-01-03  6:36 ` [PATCH v1 01/13] refactor(discord): Remove unnecessary try/except block Muhammad Rizki
2023-01-03  6:36 ` Muhammad Rizki [this message]
2023-01-03  6:36 ` [PATCH v1 03/13] refactor(telegram)!: Ensure the Telegram bot has been started Muhammad Rizki
2023-01-03  6:54   ` Ammar Faizi
2023-01-03 12:17     ` Muhammad Rizki
2023-01-03 22:11       ` Ammar Faizi
2023-01-03 22:27         ` Alviro Iskandar Setiawan
2023-01-03 22:28           ` Ammar Faizi
2023-01-04  6:31           ` Muhammad Rizki
2023-01-04  6:39             ` Alviro Iskandar Setiawan
2023-01-04  6:50               ` Muhammad Rizki
2023-01-04  6:50               ` Ammar Faizi
2023-01-04  7:02                 ` Alviro Iskandar Setiawan
2023-01-04  7:05                   ` Ammar Faizi
2023-01-03  6:36 ` [PATCH v1 04/13] feat: add DaemonException() class Muhammad Rizki
2023-01-03  6:36 ` [PATCH v1 05/13] feat(telegram): Implement the " Muhammad Rizki
2023-01-03  7:09   ` Ammar Faizi
2023-01-03  6:36 ` [PATCH v1 06/13] refactor(telegram/mailer)!: Remove unnecessary try/except block Muhammad Rizki
2023-01-03  6:36 ` [PATCH v1 07/13] feat(discord): add report_err() for the Discord bot Muhammad Rizki
2023-01-03  6:36 ` [PATCH v1 08/13] feat(discord): Implement the report_err() Muhammad Rizki
2023-01-03  7:14   ` Ammar Faizi
2023-01-03  7:17     ` Ammar Faizi
2023-01-03 12:20     ` Muhammad Rizki
2023-01-03 22:20       ` Ammar Faizi
2023-01-04  8:21         ` Muhammad Rizki
2023-01-04  8:30           ` Ammar Faizi
2023-01-04  8:37             ` Ammar Faizi
2023-01-04  8:51               ` Ammar Faizi
2023-01-07  6:10         ` Muhammad Rizki
2023-01-07  6:18           ` Ammar Faizi
2023-01-07  6:22             ` Alviro Iskandar Setiawan
2023-01-07  6:26               ` Ammar Faizi
2023-01-07  7:02               ` Muhammad Rizki
2023-01-07  7:03                 ` Ammar Faizi
2023-01-03  6:36 ` [PATCH v1 09/13] feat(discord/database): Add ping() method Muhammad Rizki
2023-01-03  6:36 ` [PATCH v1 10/13] feat(discord): Add handle_db_error in the listener.py Muhammad Rizki
2023-01-03  6:36 ` [PATCH v1 11/13] feat(discord): Handle MySQL connection error in the mail listener Muhammad Rizki
2023-01-03  7:19   ` Ammar Faizi
2023-01-03  6:36 ` [PATCH v1 12/13] feat(discord): Implement the DaemonException for handle error Muhammad Rizki
2023-01-03  6:36 ` [PATCH v1 13/13] refactor(telegram)!: Rename the Telegram bot custom client Muhammad Rizki
2023-01-03  7:25 ` [PATCH v1 00/13] Improvements, refactors, and features Ammar Faizi

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox