Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 14 additions & 34 deletions plugins/filters.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,30 +91,20 @@ async def cb_handler(client: Bot, query: CallbackQuery):
buttons.append(
[InlineKeyboardButton("⏪ BACK", callback_data=f"back_{int(index)+1}_{keyword}")]
)
buttons.append(
[InlineKeyboardButton(f"📃 Pages {int(index)+2}/{data['total']}", callback_data="pages")]
)

await query.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(buttons)
)
return
else:
buttons = data['buttons'][int(index)+1].copy()

buttons.append(
[InlineKeyboardButton("⏪ BACK", callback_data=f"back_{int(index)+1}_{keyword}"),InlineKeyboardButton("NEXT ⏩", callback_data=f"next_{int(index)+1}_{keyword}")]
)
buttons.append(
[InlineKeyboardButton(f"📃 Pages {int(index)+2}/{data['total']}", callback_data="pages")]
)

await query.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(buttons)
)
return

buttons.append(
[InlineKeyboardButton(f"📃 Pages {int(index)+2}/{data['total']}", callback_data="pages")]
)

await query.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(buttons)
)
return
Comment on lines -94 to +107
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function cb_handler refactored with the following changes:

elif query.data.startswith("back"):
await query.answer()
ident, index, keyword = query.data.split("_")
Expand All @@ -126,30 +116,20 @@ async def cb_handler(client: Bot, query: CallbackQuery):
buttons.append(
[InlineKeyboardButton("NEXT ⏩", callback_data=f"next_{int(index)-1}_{keyword}")]
)
buttons.append(
[InlineKeyboardButton(f"📃 Pages {int(index)}/{data['total']}", callback_data="pages")]
)

await query.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(buttons)
)
return
else:
buttons = data['buttons'][int(index)-1].copy()

buttons.append(
[InlineKeyboardButton("⏪ BACK", callback_data=f"back_{int(index)-1}_{keyword}"),InlineKeyboardButton("NEXT ⏩", callback_data=f"next_{int(index)-1}_{keyword}")]
)
buttons.append(
[InlineKeyboardButton(f"📃 Pages {int(index)}/{data['total']}", callback_data="pages")]
)

await query.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(buttons)
)
return

buttons.append(
[InlineKeyboardButton(f"📃 Pages {int(index)}/{data['total']}", callback_data="pages")]
)

await query.edit_message_reply_markup(
reply_markup=InlineKeyboardMarkup(buttons)
)
return
elif query.data == "pages":
await query.answer()

Expand Down