mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-23 23:32:05 +00:00
refactor, clear structure
This commit is contained in:
@@ -10,13 +10,15 @@ from telegram.ext import (ApplicationBuilder, CallbackQueryHandler, CommandHandl
|
||||
InlineQueryHandler, MessageHandler, PicklePersistence, filters)
|
||||
|
||||
import common
|
||||
import utils.regex as regex
|
||||
from utils.logger import get_logger
|
||||
from utils.telegram import Telegram
|
||||
|
||||
if TYPE_CHECKING:
|
||||
from telegram import Chat, Message, Update
|
||||
from telegram.ext import Application, ContextTypes
|
||||
|
||||
logger = common.get_logger(__name__)
|
||||
logger = get_logger(__name__)
|
||||
|
||||
|
||||
def send_action(action):
|
||||
@@ -105,7 +107,7 @@ async def edit_message(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
||||
))
|
||||
else:
|
||||
update_text = html.escape(update.message.text)
|
||||
match = common.message_url_regex.search(update_text)
|
||||
match = regex.message_url.search(update_text)
|
||||
if match:
|
||||
match = match.span()
|
||||
update_text = update_text[:match[0]] + message_url.format(
|
||||
@@ -234,8 +236,8 @@ def main():
|
||||
user_filter.add_user_ids(common.ADMIN)
|
||||
|
||||
handlers = [
|
||||
InlineQueryHandler(inline_query, common.x_url_regex),
|
||||
MessageHandler(filters.Regex(common.x_url_regex) & filters.ChatType.PRIVATE, url_media),
|
||||
InlineQueryHandler(inline_query, regex.x_url),
|
||||
MessageHandler(filters.Regex(regex.x_url) & filters.ChatType.PRIVATE, url_media),
|
||||
CommandHandler("set_forward_channel", cmd_set_forward_channel),
|
||||
CommandHandler("remove_forward_channel", cmd_remove_forward_channel),
|
||||
CommandHandler("edit_before_forward", cmd_edit_before_forward),
|
||||
|
||||
Reference in New Issue
Block a user