randydev commited on
Commit
6aa398a
·
verified ·
1 Parent(s): 8fcb1f0

Create main.py

Browse files
Files changed (1) hide show
  1. main.py +53 -0
main.py ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
7
+ logging.getLogger("pyrogram").setLevel(logging.WARNING)
8
+ logging.basicConfig(level=logging.INFO)
9
+
10
+ WELCOME_TEXT = """
11
+ Halo {}
12
+ Saya adalah bot untuk mengunduh video tiktok di telegram.
13
+
14
+ Saya dapat mengunduh video dengan tanda air atau tanpa tanda air dan mengunduh audio dari url. Kirimkan saja saya url tiktok.
15
+ """
16
+
17
+ client = Client(
18
+ "TTK-BOT",
19
+ api_id=API_ID,
20
+ api_hash=API_HASH,
21
+ bot_token=BOT_TOKEN
22
+ )
23
+
24
+ @client.on_message(filters.command("start") & filters.private)
25
+ async def welcome_start(client: Client, message: Message):
26
+ keyboard = InlineKeyboardMarkup(
27
+ [
28
+ [
29
+ InlineKeyboardButton(
30
+ text="📢 Saluran Bot",
31
+ url="https://t.me/RendyProjects"
32
+ )
33
+ ]
34
+ ]
35
+ )
36
+ await message.reply_text(
37
+ WELCOME_TEXT.format(message.from_user.first_name),
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
+ response = Tiktok(tt, query)
48
+ await message.reply_video(response[0])
49
+ await dll.delete()
50
+ except Exception as e:
51
+ await message.reply_text(f"Error: {str(e)}")
52
+
53
+ client.run()