-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
bot.py
136 lines (106 loc) · 4.01 KB
/
bot.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton, ForceReply
from pyrogram import Client, filters
from pyrogram.types import Message
# Replace 'YOUR_API_ID', 'YOUR_API_HASH', and 'YOUR_BOT_TOKEN' with your actual values
api_id =
api_hash = ''
bot_token = ''
app = Client("my_bot", api_id=api_id, api_hash=api_hash, bot_token=bot_token)
# delete button
@app.on_callback_query(filters.regex('cancel'))
async def cancel(bot,update):
try:
await update.message.delete()
except:
return
# Define start command handler
@app.on_message(filters.command("start"))
async def start_command(bot, message: Message):
# Check if the user has a first name
if message.from_user.first_name:
user_name = message.from_user.first_name
else:
user_name = "User"
# Send personalized welcome message
await message.reply_text(
text="👋 Hello \n**Send me a video, sticker, photo, Voice, Audio, or document to get its file ID.**",
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('📍 𝐔𝐩𝐝𝐚𝐭𝐞 𝐂𝐡𝐚𝐧𝐧𝐞𝐥', url='https://t.me/NT_BOT_CHANNEL'),
],
[
InlineKeyboardButton('👩💻 𝐃𝐞𝐯𝐞𝐥𝐨𝐩𝐞𝐫', url='https://t.me/LISA_FAN_LK'),
InlineKeyboardButton('🚨 𝐒𝐮𝐩𝐩𝐨𝐫𝐭 𝐆𝐫𝐨𝐮𝐩', url='https://t.me/NT_BOTS_SUPPORT'),
],
[
InlineKeyboardButton('⛔️ 𝐂𝐋𝐎𝐒𝐄', callback_data='cancel')
]
]
),
)
# Define help command handler
@app.on_message(filters.command("help"))
async def help_command(bot, message: Message):
help_msg = """
**Here's how to use this bot:**
- Send any of the following types of messages to get its file ID:
- Video
- Sticker
- Photo
- Voice
- Audio
- Document
- To start, use the /start command.
- For help, use the /help command.
**Enjoy using the bot! If you encounter any issues, feel free to contact the owner.**
**OWNER :** @LISA_FAN_LK & @YEAH_NEW
"""
await message.reply_text(help_msg)
@app.on_message(filters.private & filters.text & ~filters.forwarded)
async def handle_new_user_text(bot, message: Message):
new_user_info = {
"id": message.from_user.id,
"is_bot": message.from_user.is_bot,
"first_name": message.from_user.first_name,
"username": message.from_user.username,
"language_code": message.from_user.language_code
}
chat_info = {
"id": message.chat.id,
"type": message.chat.type,
"username": message.chat.username,
"first_name": message.chat.first_name
}
info_text = f"User Info:\n\n{new_user_info}\n\nChat Info:\n\n{chat_info}"
await message.reply_text(info_text)
# Define handlers for different types of messages
@app.on_message(filters.video)
async def handle_video(bot, message: Message):
# Handle video message
await message.reply_text(f"Video file ID: {message.video.file_id}")
@app.on_message(filters.sticker)
async def handle_sticker(bot, message: Message):
# Handle sticker message
await message.reply_text(f"Sticker file ID: {message.sticker.file_id}")
@app.on_message(filters.photo)
async def handle_photo(bot, message: Message):
# Handle photo message
await message.reply_text(f"Photo file ID: {message.photo.file_id}")
@app.on_message(filters.document)
async def handle_document(bot, message: Message):
# Handle document message
await message.reply_text(f"Document file ID: {message.document.file_id}")
# Define handlers for voice and audio messages
@app.on_message(filters.voice)
async def handle_voice(bot, message: Message):
# Handle voice message
await message.reply_text(f"Voice file ID: {message.voice.file_id}")
@app.on_message(filters.audio)
async def handle_audio(bot, message: Message):
# Handle audio message
await message.reply_text(f"Audio file ID: {message.audio.file_id}")
# Run the client
if __name__ == "__main__":
print("alive")
app.run()