From: Muhammad Rizki <[email protected]>
To: Ammar Faizi <[email protected]>
Cc: Muhammad Rizki <[email protected]>,
GNU/Weeb Mailing List <[email protected]>,
Alviro Iskandar Setiawan <[email protected]>
Subject: [RFC PATCH v1 3/5] [telegram] Renaming some functions in scraper/bot.py
Date: Tue, 6 Sep 2022 18:19:27 +0700 [thread overview]
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
Just renameing some functions...
Signed-off-by: Muhammad Rizki <[email protected]>
---
daemon/telegram/scraper/bot.py | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/daemon/telegram/scraper/bot.py b/daemon/telegram/scraper/bot.py
index 9ef5508..a7087ad 100644
--- a/daemon/telegram/scraper/bot.py
+++ b/daemon/telegram/scraper/bot.py
@@ -4,6 +4,7 @@
# Copyright (C) 2022 Ammar Faizi <[email protected]>
#
+from pyrogram.types import Message
from apscheduler.schedulers.asyncio import AsyncIOScheduler
from packages import DaemonClient
from scraper import Scraper
@@ -72,7 +73,7 @@ class Bot():
chats = self.db.get_broadcast_chats()
for chat in chats:
async with self.mutexes.send_to_tg:
- should_wait = await self.__send_to_tg(url, mail,
+ should_wait = await self.__send_mail(url, mail,
chat[1])
if should_wait:
@@ -80,7 +81,7 @@ class Bot():
# @__must_hold(self.mutexes.send_to_tg)
- async def __send_to_tg(self, url, mail, tg_chat_id):
+ async def __send_mail(self, url, mail, tg_chat_id):
email_msg_id = utils.get_email_msg_id(mail)
if not email_msg_id:
#
@@ -89,7 +90,7 @@ class Bot():
#
return False
- email_id = self.__need_to_send_to_telegram(email_msg_id,
+ email_id = self.__mail_id_from_db(email_msg_id,
tg_chat_id)
if not email_id:
#
@@ -99,16 +100,16 @@ class Bot():
return False
text, files, is_patch = utils.create_template(mail)
- reply_to = self.get_tg_reply_to(mail, tg_chat_id)
+ reply_to = self.get_reply(mail, tg_chat_id)
url = str(re.sub(r"/raw$", "", url))
if is_patch:
- m = await self.client.send_patch_email(
+ m: "Message" = await self.client.send_patch_email(
mail, tg_chat_id, text, reply_to, url
)
else:
text = "#ml\n" + text
- m = await self.client.send_text_email(
+ m: "Message" = await self.client.send_text_email(
tg_chat_id, text,reply_to, url
)
@@ -123,7 +124,7 @@ class Bot():
return True
- def __need_to_send_to_telegram(self, email_msg_id, tg_chat_id):
+ def __mail_id_from_db(self, email_msg_id, tg_chat_id):
email_id = self.db.save_email(email_msg_id)
if email_id:
return email_id
@@ -132,7 +133,7 @@ class Bot():
return email_id
- def get_tg_reply_to(self, mail, tg_chat_id):
+ def get_reply(self, mail, tg_chat_id):
reply_to = mail.get("in-reply-to")
if not reply_to:
return None
--
Muhammad Rizki
next prev parent reply other threads:[~2022-09-06 11:19 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-06 11:19 [RFC PATCH v1 0/5] Refactor some Telegram bot source code Muhammad Rizki
2022-09-06 11:19 ` [RFC PATCH v1 1/5] [telegram] Move the " Muhammad Rizki
2022-09-06 11:19 ` [RFC PATCH v1 2/5] [telegram] Refactor Telegram bot database method Muhammad Rizki
2022-09-06 11:19 ` Muhammad Rizki [this message]
2022-09-06 16:11 ` [RFC PATCH v1 3/5] [telegram] Renaming some functions in scraper/bot.py Ammar Faizi
2022-09-06 11:19 ` [RFC PATCH v1 4/5] [telegram] Remove unecessary files Muhammad Rizki
2022-09-06 16:02 ` Ammar Faizi
2022-09-06 16:46 ` Muhammad Rizki
2022-09-06 16:53 ` Ammar Faizi
2022-09-06 11:19 ` [RFC PATCH v1 5/5] Refactor many files Muhammad Rizki
2022-09-06 16:04 ` 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