Improved rules
This commit is contained in:
parent
97325b4ff5
commit
a9b5685d7b
@ -116,7 +116,9 @@
|
|||||||
"reapply_yes": "✅ Прийняти",
|
"reapply_yes": "✅ Прийняти",
|
||||||
"reapply_no": "❌ Відхилити",
|
"reapply_no": "❌ Відхилити",
|
||||||
"rules_home": "🏠 Головна",
|
"rules_home": "🏠 Головна",
|
||||||
"rules_additional": "➕ Додаткові"
|
"rules_additional": "➕ Додаткові",
|
||||||
|
"rules_next": "Далі ➡️",
|
||||||
|
"rules_prev": "⬅️ Назад"
|
||||||
},
|
},
|
||||||
"callback": {
|
"callback": {
|
||||||
"sub_accepted": "✅ Анкету {0} схвалено",
|
"sub_accepted": "✅ Анкету {0} схвалено",
|
||||||
|
42
main.py
42
main.py
@ -62,9 +62,7 @@ async def cmd_kill(app, msg):
|
|||||||
|
|
||||||
|
|
||||||
# Rules command =============================================================================================================
|
# Rules command =============================================================================================================
|
||||||
@app.on_message(~ filters.scheduled & filters.private & filters.command(["rules"], prefixes=["/"]))
|
default_rules_markup = InlineKeyboardMarkup(
|
||||||
async def cmd_rules(app, msg):
|
|
||||||
await msg.reply_text(locale("rules_msg"), disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(
|
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
InlineKeyboardButton(locale("rules_home", "button"), callback_data="rules_home"),
|
InlineKeyboardButton(locale("rules_home", "button"), callback_data="rules_home"),
|
||||||
@ -86,8 +84,11 @@ async def cmd_rules(app, msg):
|
|||||||
InlineKeyboardButton("9", callback_data="rule_9")
|
InlineKeyboardButton("9", callback_data="rule_9")
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
|
||||||
|
@app.on_message(~ filters.scheduled & filters.private & filters.command(["rules"], prefixes=["/"]))
|
||||||
|
async def cmd_rules(app, msg):
|
||||||
|
await msg.reply_text(locale("rules_msg"), disable_web_page_preview=True, reply_markup=default_rules_markup)
|
||||||
# for rule_msg in locale("rules"):
|
# for rule_msg in locale("rules"):
|
||||||
# await msg.reply_text(rule_msg)
|
# await msg.reply_text(rule_msg)
|
||||||
# ==============================================================================================================================
|
# ==============================================================================================================================
|
||||||
@ -566,8 +567,33 @@ async def callback_query_rule(app, clb):
|
|||||||
|
|
||||||
logWrite(f"User {clb.from_user.id} requested to check out rule {fullclb[1]}")
|
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 = [
|
||||||
|
InlineKeyboardButton(locale("rules_prev", "button"), callback_data=f"rule_{rule_num-1}")
|
||||||
|
]
|
||||||
|
elif rule_num == 1:
|
||||||
|
lower_buttons = [
|
||||||
|
InlineKeyboardButton(locale("rules_next", "button"), callback_data=f"rule_{rule_num+1}")
|
||||||
|
]
|
||||||
|
else:
|
||||||
|
lower_buttons = [
|
||||||
|
InlineKeyboardButton(locale("rules_prev", "button"), callback_data=f"rule_{rule_num-1}"),
|
||||||
|
InlineKeyboardButton(locale("rules_next", "button"), callback_data=f"rule_{rule_num+1}")
|
||||||
|
]
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await clb.message.edit(text=locale("rules")[int(fullclb[1])-1], disable_web_page_preview=True, reply_markup=clb.message.reply_markup)
|
await clb.message.edit(text=locale("rules")[rule_num-1], disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(
|
||||||
|
[
|
||||||
|
[
|
||||||
|
InlineKeyboardButton(locale("rules_home", "button"), callback_data="rules_home"),
|
||||||
|
InlineKeyboardButton(locale("rules_additional", "button"), callback_data="rules_additional")
|
||||||
|
],
|
||||||
|
lower_buttons
|
||||||
|
]
|
||||||
|
)
|
||||||
|
)
|
||||||
except bad_request_400.MessageNotModified:
|
except bad_request_400.MessageNotModified:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -579,7 +605,7 @@ async def callback_query_rules_home(app, clb):
|
|||||||
logWrite(f"User {clb.from_user.id} requested to check out homepage rules")
|
logWrite(f"User {clb.from_user.id} requested to check out homepage rules")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await clb.message.edit(text=locale("rules_msg"), disable_web_page_preview=True, reply_markup=clb.message.reply_markup)
|
await clb.message.edit(text=locale("rules_msg"), disable_web_page_preview=True, reply_markup=default_rules_markup)
|
||||||
except bad_request_400.MessageNotModified:
|
except bad_request_400.MessageNotModified:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -591,7 +617,7 @@ async def callback_query_rules_additional(app, clb):
|
|||||||
logWrite(f"User {clb.from_user.id} requested to check out additional rules")
|
logWrite(f"User {clb.from_user.id} requested to check out additional rules")
|
||||||
|
|
||||||
try:
|
try:
|
||||||
await clb.message.edit(text=locale("rules_additional"), disable_web_page_preview=True, reply_markup=clb.message.reply_markup)
|
await clb.message.edit(text=locale("rules_additional"), disable_web_page_preview=True, reply_markup=default_rules_markup)
|
||||||
except bad_request_400.MessageNotModified:
|
except bad_request_400.MessageNotModified:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user