public inbox for [email protected]
 help / color / mirror / Atom feed
From: Muhammad Rizki <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: Muhammad Rizki <[email protected]>,
	Alviro Iskandar Setiawan <[email protected]>,
	GNU/Weeb Mailing List <[email protected]>
Subject: [PATCH v2 11/11] telegram: Rename the Telegram bot custom client
Date: Sun,  8 Jan 2023 13:15:43 +0700	[thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>

Rename the custom client for the Telegram bot and update all affected
code in the other files to reflect the change.

Signed-off-by: Muhammad Rizki <[email protected]>
---
 daemon/telegram/mailer/listener.py                     |  4 ++--
 daemon/telegram/packages/__init__.py                   |  2 +-
 daemon/telegram/packages/client.py                     |  2 +-
 daemon/telegram/packages/decorator.py                  |  2 +-
 daemon/telegram/packages/plugins/callbacks/del_atom.py |  6 +++---
 daemon/telegram/packages/plugins/callbacks/del_chat.py |  6 +++---
 .../telegram/packages/plugins/commands/manage_atom.py  | 10 +++++-----
 .../packages/plugins/commands/manage_broadcast.py      | 10 +++++-----
 daemon/telegram/packages/plugins/commands/scrape.py    |  6 +++---
 daemon/tg.py                                           |  4 ++--
 10 files changed, 26 insertions(+), 26 deletions(-)

diff --git a/daemon/telegram/mailer/listener.py b/daemon/telegram/mailer/listener.py
index 9e5cbf5..c32ad94 100644
--- a/daemon/telegram/mailer/listener.py
+++ b/daemon/telegram/mailer/listener.py
@@ -8,7 +8,7 @@ from pyrogram import idle
 from pyrogram.types import Message
 from mysql.connector.errors import OperationalError, DatabaseError
 from apscheduler.schedulers.asyncio import AsyncIOScheduler
-from telegram.packages import DaemonClient
+from telegram.packages import DaemonTelegram
 from exceptions import DaemonException
 from atom import Scraper
 from atom import utils
@@ -23,7 +23,7 @@ class BotMutexes():
 
 
 class Bot():
-	def __init__(self, client: DaemonClient, sched: AsyncIOScheduler,
+	def __init__(self, client: DaemonTelegram, sched: AsyncIOScheduler,
 			scraper: Scraper, mutexes: BotMutexes):
 		self.client = client
 		self.sched = sched
diff --git a/daemon/telegram/packages/__init__.py b/daemon/telegram/packages/__init__.py
index efef9ae..15a270f 100644
--- a/daemon/telegram/packages/__init__.py
+++ b/daemon/telegram/packages/__init__.py
@@ -1 +1 @@
-from .client import DaemonClient
+from .client import DaemonTelegram
diff --git a/daemon/telegram/packages/client.py b/daemon/telegram/packages/client.py
index c5b0b33..a58aaf8 100644
--- a/daemon/telegram/packages/client.py
+++ b/daemon/telegram/packages/client.py
@@ -17,7 +17,7 @@ from .decorator import handle_flood
 from exceptions import DaemonException
 
 
-class DaemonClient(Client):
+class DaemonTelegram(Client):
 	def __init__(self, name: str, api_id: int,
 		api_hash: str, conn, logger: BotLogger,
 		**kwargs
diff --git a/daemon/telegram/packages/decorator.py b/daemon/telegram/packages/decorator.py
index 153fa95..efcfc38 100644
--- a/daemon/telegram/packages/decorator.py
+++ b/daemon/telegram/packages/decorator.py
@@ -24,7 +24,7 @@ def handle_flood(func: Callable[[T], T]) -> Callable[[T], T]:
 			try:
 				return await func(*args)
 			except FloodWait as e:
-				# Calling logger attr from the DaemonClient() class
+				# Calling logger attr from the DaemonTelegram() class
 				logger = args[0].logger
 
 				_flood_exceptions(e, logger)
diff --git a/daemon/telegram/packages/plugins/callbacks/del_atom.py b/daemon/telegram/packages/plugins/callbacks/del_atom.py
index b750e1c..84524c2 100644
--- a/daemon/telegram/packages/plugins/callbacks/del_atom.py
+++ b/daemon/telegram/packages/plugins/callbacks/del_atom.py
@@ -3,14 +3,14 @@
 # Copyright (C) 2022  Muhammad Rizki <[email protected]>
 #
 
-from telegram.packages import DaemonClient
+from telegram.packages import DaemonTelegram
 from atom import utils
 from pyrogram.types import CallbackQuery
 from telegram import config
 
 
[email protected]_callback_query(config.admin_only, group=1)
-async def on_del_atom(c: DaemonClient, cb: CallbackQuery):
[email protected]_callback_query(config.admin_only, group=1)
+async def on_del_atom(c: DaemonTelegram, cb: CallbackQuery):
 	if not "del_atom" in cb.data:
 		return
 
diff --git a/daemon/telegram/packages/plugins/callbacks/del_chat.py b/daemon/telegram/packages/plugins/callbacks/del_chat.py
index 90b557e..c7135e0 100644
--- a/daemon/telegram/packages/plugins/callbacks/del_chat.py
+++ b/daemon/telegram/packages/plugins/callbacks/del_chat.py
@@ -3,14 +3,14 @@
 # Copyright (C) 2022  Muhammad Rizki <[email protected]>
 #
 
-from telegram.packages import DaemonClient
+from telegram.packages import DaemonTelegram
 from atom import utils
 from pyrogram.types import CallbackQuery
 from telegram import config
 
 
[email protected]_callback_query(config.admin_only, group=2)
-async def on_del_chat(c: DaemonClient, cb: CallbackQuery):
[email protected]_callback_query(config.admin_only, group=2)
+async def on_del_chat(c: DaemonTelegram, cb: CallbackQuery):
 	if not "del_chat" in cb.data:
 		return
 
diff --git a/daemon/telegram/packages/plugins/commands/manage_atom.py b/daemon/telegram/packages/plugins/commands/manage_atom.py
index 99df7f7..f686adf 100644
--- a/daemon/telegram/packages/plugins/commands/manage_atom.py
+++ b/daemon/telegram/packages/plugins/commands/manage_atom.py
@@ -5,16 +5,16 @@
 
 from pyrogram.types import Message
 from pyrogram import filters
-from telegram.packages import DaemonClient
+from telegram.packages import DaemonTelegram
 from atom import utils
 from telegram import config
 
 
[email protected]_message(
[email protected]_message(
 	filters.command("add_atom") &
 	config.admin_only
 )
-async def add_atom_url(c: DaemonClient, m: Message):
+async def add_atom_url(c: DaemonTelegram, m: Message):
 	if len(m.command) <= 1:
 		tutor = "Please specify the URL\n"
 		tutor += "Example: `/add_atom https://lore.kernel.org/linux-sgx/new.atom`"
@@ -32,11 +32,11 @@ async def add_atom_url(c: DaemonClient, m: Message):
 	await m.reply(f"Success add **{text}** for listening new email")
 
 
[email protected]_message(
[email protected]_message(
 	filters.command("del_atom") &
 	config.admin_only
 )
-async def del_atom_url(c: DaemonClient, m: Message):
+async def del_atom_url(c: DaemonTelegram, m: Message):
 	atoms = c.db.get_atom_urls()
 	if len(atoms) == 0:
 		return await m.reply("Currently empty.")
diff --git a/daemon/telegram/packages/plugins/commands/manage_broadcast.py b/daemon/telegram/packages/plugins/commands/manage_broadcast.py
index 0aa70de..63f9547 100644
--- a/daemon/telegram/packages/plugins/commands/manage_broadcast.py
+++ b/daemon/telegram/packages/plugins/commands/manage_broadcast.py
@@ -5,16 +5,16 @@
 
 from pyrogram.types import Message
 from pyrogram import filters, enums
-from telegram.packages import DaemonClient
+from telegram.packages import DaemonTelegram
 from atom import utils
 from telegram import config
 
 
[email protected]_message(
[email protected]_message(
 	filters.command("add_bc") &
 	config.admin_only
 )
-async def add_broadcast(c: DaemonClient, m: Message):
+async def add_broadcast(c: DaemonTelegram, m: Message):
 	if m.chat.type == enums.ChatType.PRIVATE:
 		chat_name = m.chat.first_name
 	else:
@@ -37,11 +37,11 @@ async def add_broadcast(c: DaemonClient, m: Message):
 	await m.reply(msg)
 
 
[email protected]_message(
[email protected]_message(
 	filters.command("del_bc") &
 	config.admin_only
 )
-async def del_broadcast(c: DaemonClient, m: Message):
+async def del_broadcast(c: DaemonTelegram, m: Message):
 	if "--list" in m.text:
 		chats = c.db.get_broadcast_chats()
 		if len(chats) == 0:
diff --git a/daemon/telegram/packages/plugins/commands/scrape.py b/daemon/telegram/packages/plugins/commands/scrape.py
index f89727d..89581b6 100644
--- a/daemon/telegram/packages/plugins/commands/scrape.py
+++ b/daemon/telegram/packages/plugins/commands/scrape.py
@@ -6,7 +6,7 @@
 
 from pyrogram.types import Message
 from pyrogram import filters
-from telegram.packages import DaemonClient
+from telegram.packages import DaemonTelegram
 from atom import Scraper
 from atom import utils
 from enums import Platform
@@ -22,11 +22,11 @@ import asyncio
 #    .lore https://lore.kernel.org/path/message_id/raw
 #
 LORE_CMD_URL_PATTERN = r"^(?:\/|\.|\!)lore\s+(https?:\/\/lore\.kernel\.org\/\S+)"
[email protected]_message(
[email protected]_message(
 	filters.regex(LORE_CMD_URL_PATTERN) &
 	config.admin_only
 )
-async def scrap_email(c: DaemonClient, m: Message):
+async def scrap_email(c: DaemonTelegram, m: Message):
 	p = re.search(LORE_CMD_URL_PATTERN, m.text)
 	if not p:
 		return
diff --git a/daemon/tg.py b/daemon/tg.py
index a676cf5..9f36e54 100644
--- a/daemon/tg.py
+++ b/daemon/tg.py
@@ -9,7 +9,7 @@ from dotenv import load_dotenv
 from mysql import connector
 from pyrogram import idle
 from atom import Scraper
-from telegram.packages import DaemonClient
+from telegram.packages import DaemonTelegram
 from telegram.mailer import BotMutexes
 from telegram.mailer import Bot
 from logger import BotLogger
@@ -28,7 +28,7 @@ def main():
 	else:
 		port = int(port)
 
-	client = DaemonClient(
+	client = DaemonTelegram(
 		"telegram/storage/EmailScraper",
 		api_id=int(os.getenv("API_ID")),
 		api_hash=os.getenv("API_HASH"),
-- 
Muhammad Rizki


      parent reply	other threads:[~2023-01-08  6:16 UTC|newest]

Thread overview: 25+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-08  6:15 [PATCH v2 00/11] Improvements, refactors, and features Muhammad Rizki
2023-01-08  6:15 ` [PATCH v2 01/11] discord: Remove unnecessary try/except block Muhammad Rizki
2023-01-08  6:48   ` Ammar Faizi
2023-01-08  7:45     ` Muhammad Rizki
2023-01-08  6:15 ` [PATCH v2 02/11] telegram: Perform graceful exit when interrupted by a signal Muhammad Rizki
2023-01-08  6:58   ` Alviro Iskandar Setiawan
2023-01-08  7:46     ` Muhammad Rizki
2023-01-08  6:15 ` [PATCH v2 03/11] Add DaemonException() class Muhammad Rizki
2023-01-08  6:47   ` Ammar Faizi
2023-01-08  7:46     ` Muhammad Rizki
2023-01-08  6:15 ` [PATCH v2 04/11] telegram: Refactor report_err() and move to the DaemonClient() class Muhammad Rizki
2023-01-08  6:15 ` [PATCH v2 05/11] telegram: Implement the DaemonException() and refactor report_err() Muhammad Rizki
2023-01-08  6:36   ` Ammar Faizi
2023-01-08  7:15     ` Alviro Iskandar Setiawan
2023-01-08  7:23       ` Ammar Faizi
2023-01-08  7:48         ` Muhammad Rizki
2023-01-08  7:25       ` Ammar Faizi
2023-01-08  6:15 ` [PATCH v2 06/11] telegram: listener: Remove unnecessary try/except block Muhammad Rizki
2023-01-08  6:15 ` [PATCH v2 07/11] discord: add report_err() for the Discord bot Muhammad Rizki
2023-01-08  6:49   ` Ammar Faizi
2023-01-08  6:15 ` [PATCH v2 08/11] discord: Implement the report_err() and DaemonException() error class Muhammad Rizki
2023-01-08  6:15 ` [PATCH v2 09/11] discord: database: Add ping() method for reconnect MySQL Muhammad Rizki
2023-01-08  6:51   ` Ammar Faizi
2023-01-08  6:15 ` [PATCH v2 10/11] discord: listener: Add handle_db_error to handle the MySQL errors Muhammad Rizki
2023-01-08  6:15 ` Muhammad Rizki [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    [email protected] \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox