bot
commited on
Commit
·
009429f
1
Parent(s):
4cbabb4
fix
Browse files
main.py
CHANGED
@@ -233,6 +233,16 @@ async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
|
233 |
await update.message.reply_text(f"收到不支持的消息:{text}")
|
234 |
|
235 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
236 |
#################### 分享操作 #############################
|
237 |
async def tg_show_shares(update: Update, context: CallbackContext):
|
238 |
shares = await THUNDERX_CLIENT.get_share_list("")
|
@@ -246,10 +256,12 @@ async def tg_show_shares(update: Update, context: CallbackContext):
|
|
246 |
keyboard.append(
|
247 |
[
|
248 |
InlineKeyboardButton(
|
249 |
-
f"{share['title']}",
|
|
|
250 |
),
|
251 |
InlineKeyboardButton(
|
252 |
-
f"{share['share_id']}",
|
|
|
253 |
),
|
254 |
InlineKeyboardButton(
|
255 |
f"取消",
|
@@ -720,7 +732,10 @@ async def init_client():
|
|
720 |
TG_BOT_APPLICATION.add_handler(CommandHandler("shares", tg_show_shares))
|
721 |
# Message 消息处理相关的命令!
|
722 |
TG_BOT_APPLICATION.add_handler(MessageHandler(filters.TEXT, handle_message))
|
723 |
-
|
|
|
|
|
|
|
724 |
await TG_BOT_APPLICATION.initialize()
|
725 |
|
726 |
|
|
|
233 |
await update.message.reply_text(f"收到不支持的消息:{text}")
|
234 |
|
235 |
|
236 |
+
# 消息处理
|
237 |
+
async def handle_copy_text(update: Update, context: CallbackContext):
|
238 |
+
query = update.callback_query
|
239 |
+
await query.answer()
|
240 |
+
|
241 |
+
# 获取操作类型和文件 ID
|
242 |
+
action, text = (query.data.split(":")[0], query.data.split(":")[1])
|
243 |
+
await update.message.reply_text(f"{text}")
|
244 |
+
|
245 |
+
|
246 |
#################### 分享操作 #############################
|
247 |
async def tg_show_shares(update: Update, context: CallbackContext):
|
248 |
shares = await THUNDERX_CLIENT.get_share_list("")
|
|
|
256 |
keyboard.append(
|
257 |
[
|
258 |
InlineKeyboardButton(
|
259 |
+
f"{share['title']}",
|
260 |
+
callback_data=f"copy_text:{share['share_id']}",
|
261 |
),
|
262 |
InlineKeyboardButton(
|
263 |
+
f"{share['share_id']}",
|
264 |
+
callback_data=f"copy_text:{share['share_id']}",
|
265 |
),
|
266 |
InlineKeyboardButton(
|
267 |
f"取消",
|
|
|
732 |
TG_BOT_APPLICATION.add_handler(CommandHandler("shares", tg_show_shares))
|
733 |
# Message 消息处理相关的命令!
|
734 |
TG_BOT_APPLICATION.add_handler(MessageHandler(filters.TEXT, handle_message))
|
735 |
+
# 处理取消任务操作
|
736 |
+
TG_BOT_APPLICATION.add_handler(
|
737 |
+
CallbackQueryHandler(handle_copy_text, pattern="^copy_text")
|
738 |
+
)
|
739 |
await TG_BOT_APPLICATION.initialize()
|
740 |
|
741 |
|