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 AEAF08149A; Fri, 4 Nov 2022 18:10:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1667585420; bh=Pr7sZ2vd0yZ0fRb9LWDythHWmId9BtNusPstg0V0tPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=miJlL8lAcc1ColAFZHgayageVNYjtV6e59f+m8p462EDDwr+fm1Z3Q96shIcF06i8 lWBbaWtabfWAhqNHID8WavaGehGNudWD4VFE+vvOM3NvgxBHOY6d+ZnCkDxuW8N/zu 39RWf9st+fi0bXy5zFk3aMOTC2qjENPZeF/z9dLrTKlF3T9rAXZu65OrelHt16xoIj pkqZatIO+rscQckrKtiXGQGI94GlTA0UpoEFhpHdJQTvkVwSEp0QoOKthnbB8SV8Y6 h7d8l6+jDrzxXGF5Ohw0o+tGwb0nxbACDRYx31RXT9bU/EVA5HF7KDg3YBdlJ/45Zf OylYwftpnQjAw== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v1 12/15] discord: Use the BotLogger() to the GWClient() Date: Sat, 5 Nov 2022 01:09:23 +0700 Message-Id: <20221104180931.3852-17-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: 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