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 A04DD8194D; Mon, 19 Dec 2022 23:58:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gnuweeb.org; s=default; t=1671494284; bh=rmnlDun6QZZazGaBAcjX+RkXn1KN96TdTo8vgnVRgYA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=e2AwIYHvJbpyBSs+guG/yBwEjqtTeviAK8hOLGREuko+i4gFKJQYWS7vgOvBWl+bi y13h0nGH36Vaie5AvVBVWrWgpfCSlNW8aDsxjmP7n8OuiOKCurhVVXIyFchAmK8V2C vx9iIfr5FVzMPe/hvgjROwwAVTnmnwlppOhl8O+E0JeFPEDsqTUd2dPrCyhZ7XKtKw 5q9TxUUtC3JjwDSwuF3HmH2Vus3dLygPGpLzR6zi1xcgHFeTjBFpt+HI034LayQ+Sd Hw8GvG4JUqqGwV2O3vuvSNPyq9ssXDBFGox2/+wjYuJFqWmjKzXQNIlQoQXHH3BZzB bxmeUHVsiyIYw== From: Muhammad Rizki To: Ammar Faizi Cc: Muhammad Rizki , Alviro Iskandar Setiawan , GNU/Weeb Mailing List Subject: [PATCH v3 09/17] telegram: Use the created BotLogger() class Date: Tue, 20 Dec 2022 06:57:13 +0700 Message-Id: <20221219235721.126-10-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() class for the Telegram DaemonClient() class. This class is to make a log message to a file within the DaemonClient() class of the `.logger` attribute which is initialized from the BotLogger() class. Signed-off-by: Muhammad Rizki --- daemon/telegram/packages/client.py | 6 +++++- daemon/tg.py | 5 +++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/daemon/telegram/packages/client.py b/daemon/telegram/packages/client.py index c971ea1..eb282eb 100644 --- a/daemon/telegram/packages/client.py +++ b/daemon/telegram/packages/client.py @@ -10,16 +10,20 @@ from typing import Union from email.message import Message from atom import utils from enums import Platform +from logger import BotLogger from telegram.database import DB from .decorator import handle_flood class DaemonClient(Client): def __init__(self, name: str, api_id: int, - api_hash: str, conn, **kwargs): + api_hash: str, conn, logger: BotLogger, + **kwargs + ): super().__init__(name, api_id, api_hash, **kwargs) self.db = DB(conn) + self.logger = logger @handle_flood diff --git a/daemon/tg.py b/daemon/tg.py index 5f8c21e..8382c29 100644 --- a/daemon/tg.py +++ b/daemon/tg.py @@ -11,17 +11,22 @@ from atom import Scraper from telegram.packages import DaemonClient from telegram.mailer import BotMutexes from telegram.mailer import Bot +from logger import BotLogger import os def main(): load_dotenv("telegram.env") + logger = BotLogger() + logger.init() + client = DaemonClient( "telegram/storage/EmailScraper", api_id=int(os.getenv("API_ID")), api_hash=os.getenv("API_HASH"), bot_token=os.getenv("BOT_TOKEN"), + logger=logger, conn=connector.connect( host=os.getenv("DB_HOST"), user=os.getenv("DB_USER"), -- Muhammad Rizki