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 3353E81987; Mon, 19 Dec 2022 23:58:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1671494295; bh=Pr7sZ2vd0yZ0fRb9LWDythHWmId9BtNusPstg0V0tPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=gTLSGvfJQVIcxDNj3rqqQEB3xgw4byVgRhX08vTS6KxoyEJGH7ICTJXgdnpmipKtp KDaZmnn6RkSjbpf5dcH/ns7QTGmADsdCNyx155NbLocNdTE1x6MEYao6V7zMfnKz1w YeDL1O1wil1g7FjaSJa52C5CW6uBta3HaK/QPShqbsboT/+wLOmC372Rw+ox90bj1I /4eQd6WOxpenvUjrzpHw552w4AoOBRDno8aeXV1NqTnl2/WQWP4fA+wc27cGT+4EmP 62Y7KuNrTaf0d/hUugI0nwUncGu4KjaPY5yVVpA1ostva6aNejJ8uOCQ7K/+WmiPGW NrjsEKCeJZ/sA== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v3 14/17] discord: Use the BotLogger() to the GWClient() Date: Tue, 20 Dec 2022 06:57:18 +0700 Message-Id: <20221219235721.126-15-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: 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