-
Notifications
You must be signed in to change notification settings - Fork 0
/
help.py
56 lines (47 loc) · 1.61 KB
/
help.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
from pyrogram import filters as Filters
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
from ..youtube import GoogleAuth
from ..config import Config
from ..translations import Messages as tr
from ..utubebot import UtubeBot
def map_btns(pos):
if pos == 1:
button = [
[InlineKeyboardButton(text = '-->', callback_data = "help+2")]
]
elif pos == len(tr.HELP_MSG)-1:
auth = GoogleAuth(Config.CLIENT_ID, Config.CLIENT_SECRET)
url = auth.GetAuthUrl()
button = [
[InlineKeyboardButton(text = '<--', callback_data = f"help+{pos-1}")],
[InlineKeyboardButton(text = 'Authentication URL', url = url)]
]
else:
button = [
[
InlineKeyboardButton(text = '<--', callback_data = f"help+{pos-1}"),
InlineKeyboardButton(text = '-->', callback_data = f"help+{pos+1}")
],
]
return button
@UtubeBot.on_message(
Filters.private
& Filters.incoming
& Filters.command('help')
& Filters.user(Config.AUTH_USERS)
)
async def _help(c, m):
await m.reply_chat_action("typing")
await m.reply_text(
text = tr.HELP_MSG[1],
reply_markup = InlineKeyboardMarkup(map_btns(1)),
)
help_callback_filter = Filters.create(lambda _, __, query: query.data.startswith('help+'))
@UtubeBot.on_callback_query(help_callback_filter)
async def help_answer(c, q):
pos = int(q.data.split('+')[1])
await q.answer()
await q.edit_message_text(
text = tr.HELP_MSG[pos],
reply_markup = InlineKeyboardMarkup(map_btns(pos))
)