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 v1 13/13] refactor(telegram)!: Rename the Telegram bot custom client
Date: Tue, 3 Jan 2023 13:36:41 +0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Renamed all Telegram bot custom client that has been used in other files
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 e906b1f..4e1e0da 100644
--- a/daemon/telegram/mailer/listener.py
+++ b/daemon/telegram/mailer/listener.py
@@ -7,7 +7,7 @@
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
@@ -22,7 +22,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 f543caa..1c5f3b7 100644
--- a/daemon/telegram/packages/client.py
+++ b/daemon/telegram/packages/client.py
@@ -16,7 +16,7 @@ from telegram.database import DB
from .decorator import handle_flood
-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 9d50e44..d3b5760 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
next prev parent reply other threads:[~2023-01-03 6:37 UTC|newest]
Thread overview: 42+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-01-03 6:36 [PATCH v1 00/13] Improvements, refactors, and features Muhammad Rizki
2023-01-03 6:36 ` [PATCH v1 01/13] refactor(discord): Remove unnecessary try/except block Muhammad Rizki
2023-01-03 6:36 ` [PATCH v1 02/13] refactor(telegram): Move report_err() to the DaemonClient() class Muhammad Rizki
2023-01-03 6:36 ` [PATCH v1 03/13] refactor(telegram)!: Ensure the Telegram bot has been started Muhammad Rizki
2023-01-03 6:54 ` Ammar Faizi
2023-01-03 12:17 ` Muhammad Rizki
2023-01-03 22:11 ` Ammar Faizi
2023-01-03 22:27 ` Alviro Iskandar Setiawan
2023-01-03 22:28 ` Ammar Faizi
2023-01-04 6:31 ` Muhammad Rizki
2023-01-04 6:39 ` Alviro Iskandar Setiawan
2023-01-04 6:50 ` Muhammad Rizki
2023-01-04 6:50 ` Ammar Faizi
2023-01-04 7:02 ` Alviro Iskandar Setiawan
2023-01-04 7:05 ` Ammar Faizi
2023-01-03 6:36 ` [PATCH v1 04/13] feat: add DaemonException() class Muhammad Rizki
2023-01-03 6:36 ` [PATCH v1 05/13] feat(telegram): Implement the " Muhammad Rizki
2023-01-03 7:09 ` Ammar Faizi
2023-01-03 6:36 ` [PATCH v1 06/13] refactor(telegram/mailer)!: Remove unnecessary try/except block Muhammad Rizki
2023-01-03 6:36 ` [PATCH v1 07/13] feat(discord): add report_err() for the Discord bot Muhammad Rizki
2023-01-03 6:36 ` [PATCH v1 08/13] feat(discord): Implement the report_err() Muhammad Rizki
2023-01-03 7:14 ` Ammar Faizi
2023-01-03 7:17 ` Ammar Faizi
2023-01-03 12:20 ` Muhammad Rizki
2023-01-03 22:20 ` Ammar Faizi
2023-01-04 8:21 ` Muhammad Rizki
2023-01-04 8:30 ` Ammar Faizi
2023-01-04 8:37 ` Ammar Faizi
2023-01-04 8:51 ` Ammar Faizi
2023-01-07 6:10 ` Muhammad Rizki
2023-01-07 6:18 ` Ammar Faizi
2023-01-07 6:22 ` Alviro Iskandar Setiawan
2023-01-07 6:26 ` Ammar Faizi
2023-01-07 7:02 ` Muhammad Rizki
2023-01-07 7:03 ` Ammar Faizi
2023-01-03 6:36 ` [PATCH v1 09/13] feat(discord/database): Add ping() method Muhammad Rizki
2023-01-03 6:36 ` [PATCH v1 10/13] feat(discord): Add handle_db_error in the listener.py Muhammad Rizki
2023-01-03 6:36 ` [PATCH v1 11/13] feat(discord): Handle MySQL connection error in the mail listener Muhammad Rizki
2023-01-03 7:19 ` Ammar Faizi
2023-01-03 6:36 ` [PATCH v1 12/13] feat(discord): Implement the DaemonException for handle error Muhammad Rizki
2023-01-03 6:36 ` Muhammad Rizki [this message]
2023-01-03 7:25 ` [PATCH v1 00/13] Improvements, refactors, and features Ammar Faizi
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