genstava789 commited on
Commit ·
f12aa90
1
Parent(s): 93f9679
init
Browse files
bot.py
CHANGED
|
@@ -391,12 +391,17 @@ async def yt(client: Client, message: Message):
|
|
| 391 |
finally:
|
| 392 |
await load.delete()
|
| 393 |
|
| 394 |
-
@bot.on_message(filters.
|
| 395 |
-
async def
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 396 |
user_id = message.from_user.id
|
| 397 |
target_id = CHANNEL_ID if CHANNEL_ID else user_id
|
| 398 |
try:
|
| 399 |
-
url = message.text.split(maxsplit=1)[1]
|
| 400 |
progress_message = await message.reply("Processing your request...", reply_to_message_id=message.id)
|
| 401 |
|
| 402 |
video_detail = await get_video_detail(url)
|
|
@@ -438,6 +443,7 @@ async def download_tiktok(client: Client, message: Message):
|
|
| 438 |
if CHANNEL_ID:
|
| 439 |
await message.reply("Media has been sent to the specified channel. Please ensure the bot is added as an admin in the channel.", reply_to_message_id=message.id)
|
| 440 |
|
|
|
|
| 441 |
def run_bot():
|
| 442 |
loop = asyncio.new_event_loop()
|
| 443 |
asyncio.set_event_loop(loop)
|
|
|
|
| 391 |
finally:
|
| 392 |
await load.delete()
|
| 393 |
|
| 394 |
+
@bot.on_message(filters.text & filters.private)
|
| 395 |
+
async def handle_tiktok_link(client: Client, message: Message):
|
| 396 |
+
tiktok_pattern = re.compile(r"(https?://(?:www\.)?(?:tiktok\.com|vt\.tiktok\.com)/\S+)")
|
| 397 |
+
match = tiktok_pattern.search(message.text)
|
| 398 |
+
if match:
|
| 399 |
+
await process_tiktok_link(client, message, match.group(0))
|
| 400 |
+
|
| 401 |
+
async def process_tiktok_link(client: Client, message: Message, url: str):
|
| 402 |
user_id = message.from_user.id
|
| 403 |
target_id = CHANNEL_ID if CHANNEL_ID else user_id
|
| 404 |
try:
|
|
|
|
| 405 |
progress_message = await message.reply("Processing your request...", reply_to_message_id=message.id)
|
| 406 |
|
| 407 |
video_detail = await get_video_detail(url)
|
|
|
|
| 443 |
if CHANNEL_ID:
|
| 444 |
await message.reply("Media has been sent to the specified channel. Please ensure the bot is added as an admin in the channel.", reply_to_message_id=message.id)
|
| 445 |
|
| 446 |
+
|
| 447 |
def run_bot():
|
| 448 |
loop = asyncio.new_event_loop()
|
| 449 |
asyncio.set_event_loop(loop)
|