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 kanazawa.. (unknown [101.128.126.198]) by gnuweeb.org (Postfix) with ESMTPSA id ADC547E245; Fri, 4 Nov 2022 18:10:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1667585427; bh=NcCLn5qikvXNvMGdCnHCO/6dKe3BPIfZi6gVFlYcA4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Y+8/MB5MR8rsP6W4qoMX445vIGqwSuza5yPaht6bl1HdJwIo/YcUI1cYHdYwRoYEd aM3DKztKbEk3lETFNwt2TTz7a0Q4IHisuXiecVxdNGeIBiZF5QYjLhoda4VfNxfJ5s xfba86954o+loIlF/QrC5i71Tv5wlOW5Au+MqwudM5SfAH4VHRw4KccO4XQIZmCipS JKci/I9ZhPX0pE0szixpVI9XFJCdsdp3AHttFiog9ByEpmSqLM5YNW6Ec6TKYU8kK2 uegYjye6+gUztRomqWPczncQwKOulnZSckmogHvobGN206bjbs7s4ErCPajMMAOT6S WoW6KhVRstYcw== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v1 14/16] discord: Add send_log_file in the GWClient() Date: Sat, 5 Nov 2022 01:09:26 +0700 Message-Id: <20221104180931.3852-20-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221104180931.3852-1-kiizuha@gnuweeb.org> References: <20221104180931.3852-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