From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on gnuweeb.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=ALL_TRUSTED,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NO_DNS_FOR_FROM autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [101.128.126.135]) by gnuweeb.org (Postfix) with ESMTPSA id 144E77E375; Sun, 8 Jan 2023 08:08:12 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1673165294; bh=SAF/zK2OwP0srxi1BGFokTDpS8UuGb7Ou/H9G9gHzKY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=aNJgxsHJVXXPkko+9Basmdq+q/z78PkPIPUV0pV2D0qfJ1JsYU/WLDy0frxjykpo2 9btjIS66uunonrM562cOQg8Z8ZUX5+1UoiMO9wxkuphpROugQMFJefZ0Eo3EKGLhkA /k66jOgL/jh6iC1nd5xWxrAQWk+QOCZridmlL0VgdwNYxtcqENwU9N1AbHZTapoCVg qxoI+pkzTIhGvGiDCHlyS99L+c/01TG+fx2dXcyUCXqvuO0PsvpAdaSbhJkPycMVoI bm+hGLB7Q6gWQB9qqHthxnNJzBkFivY47zcviM7A09UTYR1Vq2qw/ProlOqa5Gbwle S6VRkDdecxipQ== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v3 07/11] discord: add report_err() for the Discord bot Date: Sun, 8 Jan 2023 15:07:37 +0700 Message-Id: <20230108080741.1914-8-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20230108080741.1914-1-kiizuha@gnuweeb.org> References: <20230108080741.1914-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Add report_err() in the Discord bot GWClient() class for reporting error to the Discord channel. Signed-off-by: Muhammad Rizki --- daemon/dscord/gnuweeb/client.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/daemon/dscord/gnuweeb/client.py b/daemon/dscord/gnuweeb/client.py index 406c606..78ec3f9 100644 --- a/daemon/dscord/gnuweeb/client.py +++ b/daemon/dscord/gnuweeb/client.py @@ -13,6 +13,7 @@ from . import filters from . import models from atom import utils from enums import Platform +from exceptions import DaemonException from logger.log import BotLogger from dscord.config import ACTIVITY_NAME, LOG_CHANNEL_ID from dscord.database import DB @@ -40,6 +41,13 @@ class GWClient(commands.Bot): ) + async def report_err(self, e: DaemonException): + self.logger.warning(e.original_exception) + capt = f"Atom URL: {e.atom_url}\n" + capt += f"Thread URL: {e.thread_url}" + await self.send_log_file(capt) + + @filters.wait_on_limit async def send_log_file(self, caption: str): filename = self.logger.handlers[0].baseFilename -- Muhammad Rizki