bot
commited on
Commit
·
0affc64
1
Parent(s):
48f1dab
离线功能
Browse files
main.py
CHANGED
@@ -11,6 +11,7 @@ from telegram.ext import (
|
|
11 |
CallbackQueryHandler,
|
12 |
CallbackContext,
|
13 |
ContextTypes,
|
|
|
14 |
)
|
15 |
import httpx
|
16 |
|
@@ -216,6 +217,23 @@ async def tg_emptytrash(update: Update, context):
|
|
216 |
await update.message.reply_text(f"✅操作成功")
|
217 |
|
218 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
219 |
# 确认操作的回调
|
220 |
async def handle_task_confirmation(update: Update, context: CallbackContext):
|
221 |
query = update.callback_query
|
@@ -414,6 +432,9 @@ async def init_client():
|
|
414 |
TG_BOT_APPLICATION.add_handler(CommandHandler("quota", quota))
|
415 |
TG_BOT_APPLICATION.add_handler(CommandHandler("emptytrash", tg_emptytrash))
|
416 |
TG_BOT_APPLICATION.add_handler(CommandHandler("tasks", tg_show_task))
|
|
|
|
|
|
|
417 |
await TG_BOT_APPLICATION.initialize()
|
418 |
|
419 |
|
|
|
11 |
CallbackQueryHandler,
|
12 |
CallbackContext,
|
13 |
ContextTypes,
|
14 |
+
filters,
|
15 |
)
|
16 |
import httpx
|
17 |
|
|
|
217 |
await update.message.reply_text(f"✅操作成功")
|
218 |
|
219 |
|
220 |
+
# 消息处理
|
221 |
+
async def handle_message(update: Update, context: ContextTypes.DEFAULT_TYPE):
|
222 |
+
text = update.message.text
|
223 |
+
if text.lower().startswith("magnet:"):
|
224 |
+
result = await THUNDERX_CLIENT.offline_download(text, "", "")
|
225 |
+
if result["task"]["id"] is not None:
|
226 |
+
await update.message.reply_text(f"✅操作成功")
|
227 |
+
else:
|
228 |
+
await update.message.reply_text(f"❌未成功创建任务,请稍后重试!!")
|
229 |
+
else:
|
230 |
+
await update.message.reply_text(f"收到不支持的消息:{text}")
|
231 |
+
|
232 |
+
|
233 |
+
#################### 文件操作 #############################
|
234 |
+
|
235 |
+
|
236 |
+
#################### 离线任务处理 ##########################
|
237 |
# 确认操作的回调
|
238 |
async def handle_task_confirmation(update: Update, context: CallbackContext):
|
239 |
query = update.callback_query
|
|
|
432 |
TG_BOT_APPLICATION.add_handler(CommandHandler("quota", quota))
|
433 |
TG_BOT_APPLICATION.add_handler(CommandHandler("emptytrash", tg_emptytrash))
|
434 |
TG_BOT_APPLICATION.add_handler(CommandHandler("tasks", tg_show_task))
|
435 |
+
# Message 消息处理相关的命令!
|
436 |
+
TG_BOT_APPLICATION.add_handler(MessageHandler(filters.TEXT, handle_message))
|
437 |
+
|
438 |
await TG_BOT_APPLICATION.initialize()
|
439 |
|
440 |
|