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.125.209]) by gnuweeb.org (Postfix) with ESMTPSA id 82E90819EB; Wed, 21 Dec 2022 01:34:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1671586484; bh=NcCLn5qikvXNvMGdCnHCO/6dKe3BPIfZi6gVFlYcA4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nXnD5zcQkRzH1a0mbUZNQfho2knUC+II2PWLS0yKMuJZdrXDMJsLsPy+KZ1DS1Vrw WIv8+QWXIiuAv1k2HhVLh3rlTI5e5VGSfIxSr6a0ZHjSeYJWe/uXWRz60cp+iAju37 jmE8MpkIkGNwMfzjOWLH02NH/u8R9lMSpU3gMH5g6EsBnmf8USn2gETMl2X11/WRl5 vpYu+snPJjsdNbPsqj3lVMdrhjy6r9v8exJdtbPr3ethKLtOILuWj+HNw83x8kd2oK DjFYlqKGLi8y4jD6L3/eboFmO03rfhENGajx7pDXqRUVJyhAbRnmEPG6f5cK3YMHyw khESl390XH+jw== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v4 15/17] discord: Add send_log_file in the GWClient() Date: Wed, 21 Dec 2022 08:33:45 +0700 Message-Id: <20221221013347.1704-16-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20221221013347.1704-1-kiizuha@gnuweeb.org> References: <20221221013347.1704-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