forked from No-OnE-Kn0wS-Me/FileRenameBot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhelp_text.py
260 lines (249 loc) · 9.39 KB
/
help_text.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
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# (c) Shrimadhav U K & @No_OnE_Kn0wS_Me
import logging
logging.basicConfig(level=logging.DEBUG,
format='%(asctime)s - %(name)s - %(levelname)s - %(message)s')
logger = logging.getLogger(__name__)
import os
import time
# the secret configuration specific things
if bool(os.environ.get("WEBHOOK", False)):
from sample_config import Config
else:
from config import Config
# the Strings used for this "thing"
from translation import Translation
import pyrogram
logging.getLogger("pyrogram").setLevel(logging.WARNING)
from pyrogram import filters
from pyrogram import Client as Mai_bOTs
#from helper_funcs.chat_base import TRChatBase
from helper_funcs.display_progress import progress_for_pyrogram
from pyrogram.errors import UserNotParticipant, UserBannedInChannel
from pyrogram.types import ReplyKeyboardMarkup, InlineKeyboardMarkup, InlineKeyboardButton, CallbackQuery
from hachoir.metadata import extractMetadata
from hachoir.parser import createParser
# https://stackoverflow.com/a/37631799/4723940
from PIL import Image
from database.database import *
from database.db import *
@Mai_bOTs.on_message(pyrogram.filters.command(["help"]))
async def help_user(bot, update):
update_channel = Config.UPDATE_CHANNEL
if update_channel:
try:
user = await bot.get_chat_member(update_channel, update.chat.id)
if user.status == "kicked":
await update.reply_text(" Sorry, You're Banned")
return
except UserNotParticipant:
await update.reply_text(
text="**Due To The Huge Traffic Only Channel Members Can Use This Bot Means You Need To Join The Below Mentioned Channel Before Using Me! **",
reply_markup=InlineKeyboardMarkup([
[ InlineKeyboardButton(text="Join My Updates Channel", url=f"https://t.me/{update_channel}")]
])
)
return
else:
await bot.send_message(
chat_id=update.chat.id,
text=Translation.HELP_USER,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('📝Rename', callback_data = "rnme"),
InlineKeyboardButton('📂File To Video', callback_data = "f2v")
],
[
InlineKeyboardButton('🎞️Custom Thumbnail', callback_data = "cthumb"),
InlineKeyboardButton('📑Custom Caption', callback_data = "ccaption")
],
[
InlineKeyboardButton('💬About', callback_data = "about")
]
]
)
)
@Mai_bOTs.on_message(pyrogram.filters.command(["start"]))
async def start_me(bot, update):
if update.from_user.id in Config.BANNED_USERS:
await update.reply_text("You are Banned")
return
update_channel = Config.UPDATE_CHANNEL
if update_channel:
try:
user = await bot.get_chat_member(update_channel, update.chat.id)
if user.status == "kicked":
await update.reply_text(" Sorry,You've Been Flooding Me So My Owner Removed You From Using Me If You Think It's An Error Contact : @Faris_TG")
return
except UserNotParticipant:
await update.reply_text(
text="**Due To The Huge Traffic Only Channel Members Can Use This Bot Means You Need To Join The Below Mentioned Channel Before Using Me! **",
reply_markup=InlineKeyboardMarkup([
[ InlineKeyboardButton(text="Join My Updates Channel", url=f"https://t.me/{update_channel}")]
])
)
return
else:
await update.reply_text(Translation.START_TEXT.format(update.from_user.first_name),
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton("Help", callback_data = "ghelp")
],
[
InlineKeyboardButton('Support Channel', url='https://t.me/Mai_bOTs'),
InlineKeyboardButton('Feedback', url='https://t.me/No_OnE_Kn0wS_Me')
],
[
InlineKeyboardButton('Other Bots', url='https://t.me/Mai_bOTs/17'),
InlineKeyboardButton('Source', url='https://github.com/No-OnE-Kn0wS-Me/FileRenameBot')
]
]
),
reply_to_message_id=update.message_id
)
return
@Mai_bOTs.on_callback_query()
async def cb_handler(client: Mai_bOTs , query: CallbackQuery):
data = query.data
if data == "rnme":
await query.message.edit_text(
text=Translation.RENAME_HELP,
disable_web_page_preview = True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Back', callback_data = "ghelp"),
InlineKeyboardButton("🔒 Close", callback_data = "close")
]
]
)
)
elif data == "f2v":
await query.message.edit_text(
text=Translation.C2V_HELP,
disable_web_page_preview = True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Back', callback_data = "ghelp"),
InlineKeyboardButton("🔒 Close", callback_data = "close")
]
]
)
)
elif data == "ccaption":
await query.message.edit_text(
text=Translation.CCAPTION_HELP,
disable_web_page_preview = True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Show Current Caption', callback_data = "shw_caption"),
InlineKeyboardButton("Delete Caption", callback_data = "d_caption")
],
[
InlineKeyboardButton('Back', callback_data = "ghelp"),
InlineKeyboardButton('🔒 Close', callback_data = "close")
]
]
)
)
elif data == "cthumb":
await query.message.edit_text(
text=Translation.THUMBNAIL_HELP,
disable_web_page_preview = True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Back', callback_data = "ghelp"),
InlineKeyboardButton("🔒 Close", callback_data = "close")
]
]
)
)
elif data == "closeme":
await query.message.delete()
try:
await query.message.reply_text(
text = "<b>Process Cancelled</b>"
)
except:
pass
elif data == "ghelp":
await query.message.edit_text(
text=Translation.HELP_USER,
disable_web_page_preview = True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('📝Rename', callback_data = "rnme"),
InlineKeyboardButton('📂File To Video', callback_data = "f2v")
],
[
InlineKeyboardButton('🎞️Custom Thumbnail', callback_data = "cthumb"),
InlineKeyboardButton('📑Custom Caption', callback_data = "ccaption")
],
[
InlineKeyboardButton('💬About', callback_data = "about")
]
]
)
)
elif data =="shw_caption":
try:
caption = await get_caption(query.from_user.id)
c_text = caption.caption
except:
c_text = "Sorry but you haven't added any caption yet please set your caption through /scaption command"
await query.message.edit(
text=f"<b>Your Custom Caption:</b> \n\n{c_text} ",
parse_mode="html",
disable_web_page_preview=True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Back', callback_data = "ccaption"),
InlineKeyboardButton("🔒 Close", callback_data = "close")
]
]
)
)
elif data == "about":
await query.message.edit_text(
text=Translation.ABOUT_ME,
disable_web_page_preview = True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Back', callback_data = "ghelp"),
InlineKeyboardButton("🔒 Close", callback_data = "close")
]
]
)
)
elif data == "d_caption":
try:
await del_caption(query.from_user.id)
except:
pass
await query.message.edit_text(
text="<b>caption deleted successfully</b>",
disable_web_page_preview = True,
reply_markup=InlineKeyboardMarkup(
[
[
InlineKeyboardButton('Back', callback_data = "ccaption"),
InlineKeyboardButton("🔒 Close", callback_data = "close")
]
]
)
)
elif data == "close":
await query.message.delete()
try:
await query.message.reply_to_message.delete()
except:
pass