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 102D1804D1; Wed, 9 Nov 2022 02:50:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1667962253; bh=Pr7sZ2vd0yZ0fRb9LWDythHWmId9BtNusPstg0V0tPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ckid5RY+cNG6dZxbxcFY/6Fe1y/7RmnPE5dgb7CDJqmCaRjg9klbIwj8X2M9PjGGn xDOyEyUSzVY8adfLgaVVVd0vxxqB/wU+jzBwFcciO6LTPP3bZ8IqZOKROMh6wMawVA TKZDfIfdTxMoPn/n/+eHubJQ3yhCdk42m9741A0lYuhtiXY2YGK9ZH4sehEsYCJ/br deR3IQu60x8dchbt8DpbhZ+lEh0imyXpu5ccxvfTuMyILH9eDhIBBdgkrqJzmA0TLt 85MGsAFlpJV4BSStugkPr8+XVdpoEF4DTyeiZ1j5OrwnzkKzdZAvpYGLbShJDFt3dV tzX5NxR+sqH8g== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v2 14/17] discord: Use the BotLogger() to the GWClient() Date: Wed, 9 Nov 2022 09:49:59 +0700 Message-Id: <20221109025002.258-15-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: Use the BotLogger() and initialized it to the GWClient() class attribute `.logger` to use it in the future use for log a message into the file. Signed-off-by: Muhammad Rizki --- daemon/dc.py | 10 ++++++++-- daemon/dscord/gnuweeb/client.py | 6 ++++-- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/daemon/dc.py b/daemon/dc.py index 5028e94..f9b57e5 100644 --- a/daemon/dc.py +++ b/daemon/dc.py @@ -11,6 +11,8 @@ from apscheduler.schedulers.asyncio import AsyncIOScheduler from dscord.gnuweeb import GWClient from dscord.mailer import Listener from dscord.mailer import Mutexes +from enums.platform import Platform +from logger import BotLogger from atom import Scraper @@ -24,13 +26,17 @@ def main(): } ) + logger = BotLogger(Platform.DISCORD) + logger.init() + client = GWClient( db_conn=connector.connect( host=os.getenv("DB_HOST"), user=os.getenv("DB_USER"), password=os.getenv("DB_PASS"), database=os.getenv("DB_NAME") - ) + ), + logger=logger ) mailer = Listener( @@ -39,8 +45,8 @@ def main(): scraper=Scraper(), mutexes=Mutexes() ) - client.mailer = mailer + client.mailer = mailer client.run(os.getenv("DISCORD_TOKEN"), log_handler=None) diff --git a/daemon/dscord/gnuweeb/client.py b/daemon/dscord/gnuweeb/client.py index 82858c5..42bd405 100644 --- a/daemon/dscord/gnuweeb/client.py +++ b/daemon/dscord/gnuweeb/client.py @@ -7,22 +7,24 @@ import discord from discord import Interaction from discord.ext import commands from discord import Intents -from dscord.config import ACTIVITY_NAME from typing import Union from . import filters from . import models from atom import utils from enums import Platform +from logger.log import BotLogger +from dscord.config import ACTIVITY_NAME from dscord.database import DB class GWClient(commands.Bot): - def __init__(self, db_conn) -> None: + def __init__(self, db_conn, logger: BotLogger) -> None: self.db = DB(db_conn) intents = Intents.default() intents.message_content = True self.mailer = None + self.logger = logger super().__init__( command_prefix=["$", "."], description="Just a bot for receiving lore emails.", -- Muhammad Rizki