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} схвалено",
|
||||||
|
80
main.py
80
main.py
@ -62,32 +62,33 @@ async def cmd_kill(app, msg):
|
|||||||
|
|
||||||
|
|
||||||
# Rules command =============================================================================================================
|
# Rules command =============================================================================================================
|
||||||
|
default_rules_markup = InlineKeyboardMarkup(
|
||||||
|
[
|
||||||
|
[
|
||||||
|
InlineKeyboardButton(locale("rules_home", "button"), callback_data="rules_home"),
|
||||||
|
InlineKeyboardButton(locale("rules_additional", "button"), callback_data="rules_additional")
|
||||||
|
],
|
||||||
|
[
|
||||||
|
InlineKeyboardButton("1", callback_data="rule_1"),
|
||||||
|
InlineKeyboardButton("2", callback_data="rule_2"),
|
||||||
|
InlineKeyboardButton("3", callback_data="rule_3")
|
||||||
|
],
|
||||||
|
[
|
||||||
|
InlineKeyboardButton("4", callback_data="rule_4"),
|
||||||
|
InlineKeyboardButton("5", callback_data="rule_5"),
|
||||||
|
InlineKeyboardButton("6", callback_data="rule_6")
|
||||||
|
],
|
||||||
|
[
|
||||||
|
InlineKeyboardButton("7", callback_data="rule_7"),
|
||||||
|
InlineKeyboardButton("8", callback_data="rule_8"),
|
||||||
|
InlineKeyboardButton("9", callback_data="rule_9")
|
||||||
|
]
|
||||||
|
]
|
||||||
|
)
|
||||||
|
|
||||||
@app.on_message(~ filters.scheduled & filters.private & filters.command(["rules"], prefixes=["/"]))
|
@app.on_message(~ filters.scheduled & filters.private & filters.command(["rules"], prefixes=["/"]))
|
||||||
async def cmd_rules(app, msg):
|
async def cmd_rules(app, msg):
|
||||||
await msg.reply_text(locale("rules_msg"), disable_web_page_preview=True, reply_markup=InlineKeyboardMarkup(
|
await msg.reply_text(locale("rules_msg"), disable_web_page_preview=True, reply_markup=default_rules_markup)
|
||||||
[
|
|
||||||
[
|
|
||||||
InlineKeyboardButton(locale("rules_home", "button"), callback_data="rules_home"),
|
|
||||||
InlineKeyboardButton(locale("rules_additional", "button"), callback_data="rules_additional")
|
|
||||||
],
|
|
||||||
[
|
|
||||||
InlineKeyboardButton("1", callback_data="rule_1"),
|
|
||||||
InlineKeyboardButton("2", callback_data="rule_2"),
|
|
||||||
InlineKeyboardButton("3", callback_data="rule_3")
|
|
||||||
],
|
|
||||||
[
|
|
||||||
InlineKeyboardButton("4", callback_data="rule_4"),
|
|
||||||
InlineKeyboardButton("5", callback_data="rule_5"),
|
|
||||||
InlineKeyboardButton("6", callback_data="rule_6")
|
|
||||||
],
|
|
||||||
[
|
|
||||||
InlineKeyboardButton("7", callback_data="rule_7"),
|
|
||||||
InlineKeyboardButton("8", callback_data="rule_8"),
|
|
||||||
InlineKeyboardButton("9", callback_data="rule_9")
|
|
||||||
]
|
|
||||||
]
|
|
||||||
)
|
|
||||||
)
|
|
||||||
# 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