2022-12-05 19:49:51 +02:00
|
|
|
from app import app
|
|
|
|
from pyrogram.types import InlineKeyboardMarkup, InlineKeyboardButton
|
|
|
|
from pyrogram.errors import bad_request_400
|
2022-12-05 19:53:09 +02:00
|
|
|
from pyrogram import filters
|
2022-12-05 19:49:51 +02:00
|
|
|
from modules.utils import locale, logWrite
|
|
|
|
from modules.commands.rules import default_rules_markup
|
|
|
|
|
|
|
|
# Callback rule ================================================================================================================
|
|
|
|
@app.on_callback_query(filters.regex("rule_[\s\S]*")) # type: ignore
|
|
|
|
async def callback_query_rule(app, clb):
|
|
|
|
|
|
|
|
fullclb = clb.data.split("_")
|
|
|
|
|
|
|
|
logWrite(f"User {clb.from_user.id} requested to check out rule {fullclb[1]}")
|
|
|
|
|
|
|
|
rule_num = int(fullclb[1])
|
|
|
|
|
|
|
|
if rule_num == len(locale("rules")):
|
|
|
|
lower_buttons = [
|
2022-12-05 21:52:21 +02:00
|
|
|
InlineKeyboardButton(locale("rules_prev", "button"), callback_data=f"rule_{rule_num-1}") # type: ignore
|
2022-12-05 19:49:51 +02:00
|
|
|
]
|
|
|
|
elif rule_num == 1:
|
|
|
|
lower_buttons = [
|
2022-12-05 21:52:21 +02:00
|
|
|
InlineKeyboardButton(locale("rules_next", "button"), callback_data=f"rule_{rule_num+1}") # type: ignore
|
2022-12-05 19:49:51 +02:00
|
|
|
]
|
|
|
|
else:
|
|
|
|
lower_buttons = [
|
2022-12-05 21:52:21 +02:00
|
|
|
InlineKeyboardButton(locale("rules_prev", "button"), callback_data=f"rule_{rule_num-1}"), # type: ignore
|
|
|
|
InlineKeyboardButton(locale("rules_next", "button"), callback_data=f"rule_{rule_num+1}") # type: ignore
|
2022-12-05 19:49:51 +02:00
|
|
|
]
|
|
|
|
|
|
|
|
try:
|
|
|
|
await clb.message.edit(text=locale("rules")[rule_num-1], disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(
|
|
|
|
[
|
|
|
|
[
|
2022-12-05 21:52:21 +02:00
|
|
|
InlineKeyboardButton(locale("rules_home", "button"), callback_data="rules_home"), # type: ignore
|
|
|
|
InlineKeyboardButton(locale("rules_additional", "button"), callback_data="rules_additional") # type: ignore
|
2022-12-05 19:49:51 +02:00
|
|
|
],
|
|
|
|
lower_buttons
|
|
|
|
]
|
|
|
|
)
|
|
|
|
)
|
|
|
|
except bad_request_400.MessageNotModified:
|
|
|
|
pass
|
|
|
|
|
|
|
|
await clb.answer(text=locale("rules_page", "callback").format(fullclb[1])) # type: ignore
|
|
|
|
|
|
|
|
@app.on_callback_query(filters.regex("rules_home")) # type: ignore
|
|
|
|
async def callback_query_rules_home(app, clb):
|
|
|
|
|
|
|
|
logWrite(f"User {clb.from_user.id} requested to check out homepage rules")
|
|
|
|
|
|
|
|
try:
|
|
|
|
await clb.message.edit(text=locale("rules_msg"), disable_web_page_preview=True, reply_markup=default_rules_markup)
|
|
|
|
except bad_request_400.MessageNotModified:
|
|
|
|
pass
|
|
|
|
|
|
|
|
await clb.answer(text=locale("rules_home", "callback")) # type: ignore
|
|
|
|
|
|
|
|
@app.on_callback_query(filters.regex("rules_additional")) # type: ignore
|
|
|
|
async def callback_query_rules_additional(app, clb):
|
|
|
|
|
|
|
|
logWrite(f"User {clb.from_user.id} requested to check out additional rules")
|
|
|
|
|
|
|
|
try:
|
|
|
|
await clb.message.edit(text=locale("rules_additional"), disable_web_page_preview=True, reply_markup=default_rules_markup)
|
|
|
|
except bad_request_400.MessageNotModified:
|
|
|
|
pass
|
|
|
|
|
|
|
|
await clb.answer(text=locale("rules_additional", "callback")) # type: ignore
|
|
|
|
# ==============================================================================================================================
|