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.125.209]) by gnuweeb.org (Postfix) with ESMTPSA id 6DCE78198C; Mon, 19 Dec 2022 23:58:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1671494298; bh=NcCLn5qikvXNvMGdCnHCO/6dKe3BPIfZi6gVFlYcA4s=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eOeigyC/7OwYAdZMlp9OpTZeYsmn1vHXmQMt9dzJMB/qth3w0aSHyfdBMlzm+Mrcj zVSrv0oLEj+yUX+DBU12pE8dfBFLRB9uIGJqMoACvqQeUt0YDjONZ6SmlhKGJ1pYZY eBy4gLuBvvniOYODvPqQONI+KZ7gfBbeoKr8VcJIF94zCQqPg6zJHsTPptgJIKLuX/ 9yP8cqYrpTlPFo8gQFYjlVMb6ocihZcNmIPp/4SPM1RlMWTv/+KWpjX6rlbfgl9YS6 nEEqrCA9pn/E29Xj9YdjNha3z7wxqlr9eh/AowDaajQo1Tll7ejne2h42miWKTO43K 7ydxrGOd+MIag== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v3 15/17] discord: Add send_log_file in the GWClient() Date: Tue, 20 Dec 2022 06:57:19 +0700 Message-Id: <20221219235721.126-16-kiizuha@gnuweeb.org> X-Mailer: git-send-email 2.34.1.windows.1 In-Reply-To: <20221219235721.126-1-kiizuha@gnuweeb.org> References: <20221219235721.126-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