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 345C07E581; Sun, 8 Jan 2023 06:16:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1673158576; bh=J3C9X/w3WlkwV7ffE89REUYkr2YW5/J8Be9Wp5/N7es=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lozX5ZkqRvvURRdm/5aeQjf+mlOQMVf9L0nA/Hoqtj11K/a40QVnuUV65v6bWXC9i pCKja8lbzsrbkEnedqt+ZpQxCFZxtJySh1O8XVkPLJh9z001P12qzErBrdY7ru8JN9 WireyqLp7+iypcHHWk6V8DXSfYf0urv54R2HTrMVFKsCBtJpx8R4Ggzei0tr06C74e sU2s9eDGg36Mb1siUCdORo4H9QMIyhi0pGjkzB2X7yOLk189cW4+iDk+EjB93sUajW ht2qQdpCJkkxVdHzhwseAvAu8sG6CRhBDWAU+vCxoOjHvgcmys1DyxHQasAgWWBiqr A5YGqD7P/jmlQ== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v2 07/11] discord: add report_err() for the Discord bot Date: Sun, 8 Jan 2023 13:15:39 +0700 Message-Id: <20230108061543.1780-8-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20230108061543.1780-1-kiizuha@gnuweeb.org> References: <20230108061543.1780-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Added 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