randydev commited on
Commit
10142c8
·
verified ·
1 Parent(s): 7d771af

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +27 -4
main.py CHANGED
@@ -1,6 +1,7 @@
1
  import logging
2
  from pyrogram import Client, filters
3
  from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
 
4
  from RyuzakiLib import Tiktok
5
  from config import TIKTOK_WEB as tt, API_ID, API_HASH, BOT_TOKEN
6
 
@@ -38,18 +39,40 @@ async def welcome_start(client: Client, message: Message):
38
  reply_markup=keyboard
39
  )
40
 
 
 
 
 
 
 
 
 
 
 
 
 
41
  @client.on_message(filters.text & filters.private)
42
  async def tiktok_downloader(client: Client, message: Message):
43
  if message.text:
 
 
 
 
 
 
 
 
 
 
 
44
  try:
45
- query = message.text
46
  dll = await message.reply_text("Processing....")
47
  await message.delete()
48
  response = Tiktok.download(tt, query)
49
- await message.reply_video(response[0])
50
  await dll.delete()
51
  except Exception as e:
52
- await message.reply_text(f"Error: {str(e)}")
53
  await dll.delete()
 
54
 
55
- client.run()
 
1
  import logging
2
  from pyrogram import Client, filters
3
  from pyrogram.types import Message, InlineKeyboardMarkup, InlineKeyboardButton
4
+ from pyrogram.types import *
5
  from RyuzakiLib import Tiktok
6
  from config import TIKTOK_WEB as tt, API_ID, API_HASH, BOT_TOKEN
7
 
 
39
  reply_markup=keyboard
40
  )
41
 
42
+ @client.on_callback_query(filters.regex("^audiodownload_"))
43
+ async def callback_button(client: Client, cb: CallbackQuery):
44
+ try:
45
+ data = cb.data.split("_")
46
+ user_id = int(data[1].split("|")[0])
47
+ link = cb.data.split("|")[1]
48
+ response = Tiktok.download(tt, link)
49
+ await client.send_audio(user_id, response[1])
50
+ await cb.answer("Audio sent successfully!")
51
+ except Exception as e:
52
+ await cb.answer(f"Error: {str(e)}", show_alert=True)
53
+
54
  @client.on_message(filters.text & filters.private)
55
  async def tiktok_downloader(client: Client, message: Message):
56
  if message.text:
57
+ query = message.text
58
+ keyboard = InlineKeyboardMarkup(
59
+ [
60
+ [
61
+ InlineKeyboardButton(
62
+ text="Audio Download",
63
+ callback_data=f"audiodownload_{message.from_user.id}|{query}"
64
+ )
65
+ ]
66
+ ]
67
+ )
68
  try:
 
69
  dll = await message.reply_text("Processing....")
70
  await message.delete()
71
  response = Tiktok.download(tt, query)
72
+ await message.reply_video(response[0], reply_markup=keyboard)
73
  await dll.delete()
74
  except Exception as e:
 
75
  await dll.delete()
76
+ await message.reply_text(f"Error: {str(e)}")
77
 
78
+ client.run()