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,URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.6 Received: from localhost.localdomain (unknown [101.128.126.198]) by gnuweeb.org (Postfix) with ESMTPSA id 65F2581565; Wed, 9 Nov 2022 02:50:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1667962256; bh=NcCLn5qikvXNvMGdCnHCO/6dKe3BPIfZi6gVFlYcA4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Akoe0+VmebXPYNuZNSC0ThC9ycpha8XfoR9TspDWsvjfpHDsKwZOHdVYiYhlxbmI3 d7hb4TJPY2aiGY95rT0z4rLha1ad9QAA8SgvHqLbMDM72KGnGTBin43tSQHrx9OqpM ubMPKU0WEwQeedUcEUw46r5ii7bHxfgTNk1Xrf+8wkyikDI5aauCtmgwLjT30JKT6S 3PAGlQP8CZFagm1AhdmaAj7Nc2m38AGd2V2BMPdw/jJ3TpHgpqqYvkzPrt1ZjcZYrk F3IxCgXUTZ2SZdQekuOFrSKx/zY7O62iAms2PFTqOcomfOVibjDpzdEOSiZtQpiDDO oLoQgHoeFgtYQ== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v2 15/17] discord: Add send_log_file in the GWClient() Date: Wed, 9 Nov 2022 09:50:00 +0700 Message-Id: <20221109025002.258-16-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20221109025002.258-1-kiizuha@gnuweeb.org> References: <20221109025002.258-1-kiizuha@gnuweeb.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit List-Id: Add send_log_file() to send a log file into the Discord channel for logs using the `config.LOG_CHANNEL_ID` to send it to the Discord channel. Signed-off-by: Muhammad Rizki --- daemon/dscord/gnuweeb/client.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/daemon/dscord/gnuweeb/client.py b/daemon/dscord/gnuweeb/client.py index 42bd405..1b260ea 100644 --- a/daemon/dscord/gnuweeb/client.py +++ b/daemon/dscord/gnuweeb/client.py @@ -14,7 +14,7 @@ from . import models from atom import utils from enums import Platform from logger.log import BotLogger -from dscord.config import ACTIVITY_NAME +from dscord.config import ACTIVITY_NAME, LOG_CHANNEL_ID from dscord.database import DB @@ -40,6 +40,16 @@ class GWClient(commands.Bot): ) + @filters.wait_on_limit + async def send_log_file(self, caption: str): + filename = self.logger.handlers[0].baseFilename + channel = self.get_channel(LOG_CHANNEL_ID) + await channel.send( + content=caption, + file=discord.File(filename) + ) + + @filters.wait_on_limit async def send_text_email(self, guild_id: int, chat_id: int, text: str, reply_to: Union[int, None] = None, url: str = None): -- Muhammad Rizki