mirror of
https://github.com/TheFunny/TelegramTwitterMediaBot.git
synced 2026-09-25 23:52:04 +00:00
Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e700ae65ae
|
||
|
|
9ac6065366
|
||
|
|
40877b52eb
|
@@ -2,7 +2,7 @@ import html
|
|||||||
from functools import wraps
|
from functools import wraps
|
||||||
|
|
||||||
from aiohttp import ClientSession
|
from aiohttp import ClientSession
|
||||||
from telegram import Update, Chat, InlineKeyboardMarkup, InlineKeyboardButton, ForceReply, Message
|
from telegram import Update, Chat, InlineKeyboardMarkup, InlineKeyboardButton, Message
|
||||||
from telegram.constants import ParseMode, ChatAction, ChatType
|
from telegram.constants import ParseMode, ChatAction, ChatType
|
||||||
from telegram.ext import (
|
from telegram.ext import (
|
||||||
Application,
|
Application,
|
||||||
@@ -56,8 +56,10 @@ async def url_media(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
|||||||
url = tweet.url
|
url = tweet.url
|
||||||
if context.user_data.get('edit_before_forward', False):
|
if context.user_data.get('edit_before_forward', False):
|
||||||
message_reply = await update.effective_message.reply_text(
|
message_reply = await update.effective_message.reply_text(
|
||||||
"Reply to edit message.",
|
"Reply to edit message. [URL]",
|
||||||
reply_markup=ForceReply(selective=True, input_field_placeholder="[URL]"),
|
reply_markup=InlineKeyboardMarkup.from_button(
|
||||||
|
InlineKeyboardButton("↩️ Confirm", callback_data="forward")
|
||||||
|
),
|
||||||
reply_to_message_id=update.message.message_id,
|
reply_to_message_id=update.message.message_id,
|
||||||
)
|
)
|
||||||
context.user_data['message_reply'] = message_reply
|
context.user_data['message_reply'] = message_reply
|
||||||
@@ -96,11 +98,6 @@ async def edit_message(update: Update, context: ContextTypes.DEFAULT_TYPE) -> No
|
|||||||
) + update_text[match[1]:]
|
) + update_text[match[1]:]
|
||||||
message_to_send = context.user_data['message_to_send']
|
message_to_send = context.user_data['message_to_send']
|
||||||
await message_to_send[0].edit_caption(update_text)
|
await message_to_send[0].edit_caption(update_text)
|
||||||
await context.user_data['message_reply'].edit_reply_markup(
|
|
||||||
InlineKeyboardMarkup.from_button(
|
|
||||||
InlineKeyboardButton("↩️ Confirm", callback_data="forward")
|
|
||||||
)
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
async def query_forward_message(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
async def query_forward_message(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||||
@@ -156,12 +153,20 @@ async def cmd_edit_before_forward(update: Update, context: ContextTypes.DEFAULT_
|
|||||||
ebf_status = context.user_data.get('edit_before_forward', False)
|
ebf_status = context.user_data.get('edit_before_forward', False)
|
||||||
if ebf_status:
|
if ebf_status:
|
||||||
context.user_data['edit_before_forward'] = False
|
context.user_data['edit_before_forward'] = False
|
||||||
|
context.user_data.pop('message_reply', None)
|
||||||
|
context.user_data.pop('message_to_send', None)
|
||||||
|
context.user_data.pop('message_url', None)
|
||||||
await update.effective_message.reply_text("Disable edit before forward.")
|
await update.effective_message.reply_text("Disable edit before forward.")
|
||||||
return
|
return
|
||||||
context.user_data['edit_before_forward'] = True
|
context.user_data['edit_before_forward'] = True
|
||||||
await update.effective_message.reply_text("Enable edit before forward.")
|
await update.effective_message.reply_text("Enable edit before forward.")
|
||||||
|
|
||||||
|
|
||||||
|
@send_action(ChatAction.TYPING)
|
||||||
|
async def cmd_user_dict(update: Update, context: ContextTypes.DEFAULT_TYPE) -> None:
|
||||||
|
await update.effective_message.reply_text(str(context.user_data))
|
||||||
|
|
||||||
|
|
||||||
async def post_init(application: Application) -> None:
|
async def post_init(application: Application) -> None:
|
||||||
# commands = [
|
# commands = [
|
||||||
# BotCommand('start', CMD_START),
|
# BotCommand('start', CMD_START),
|
||||||
@@ -194,8 +199,8 @@ def main():
|
|||||||
.build()
|
.build()
|
||||||
)
|
)
|
||||||
|
|
||||||
# user_filter = filters.User()
|
user_filter = filters.User()
|
||||||
# user_filter.add_user_ids(common.admin)
|
user_filter.add_user_ids(common.ADMIN)
|
||||||
|
|
||||||
handlers = [
|
handlers = [
|
||||||
MessageHandler(filters.Regex(common.x_url_regex) & filters.ChatType.PRIVATE, url_media),
|
MessageHandler(filters.Regex(common.x_url_regex) & filters.ChatType.PRIVATE, url_media),
|
||||||
@@ -205,6 +210,7 @@ def main():
|
|||||||
CommandHandler("edit_before_forward", cmd_edit_before_forward),
|
CommandHandler("edit_before_forward", cmd_edit_before_forward),
|
||||||
MessageHandler(~filters.COMMAND & filters.ChatType.PRIVATE, edit_message),
|
MessageHandler(~filters.COMMAND & filters.ChatType.PRIVATE, edit_message),
|
||||||
CallbackQueryHandler(query_forward_message, pattern="forward"),
|
CallbackQueryHandler(query_forward_message, pattern="forward"),
|
||||||
|
CommandHandler("bot_dict", cmd_user_dict, filters=user_filter),
|
||||||
]
|
]
|
||||||
|
|
||||||
application.add_handlers(handlers)
|
application.add_handlers(handlers)
|
||||||
|
|||||||
Reference in New Issue
Block a user