Telezab/app/bot/keyboards/groups.py
Vladislav Zverev 0169bf5d6b refactor(alerts): improve active problem fetching and message formatting
Reworked the logic for retrieving data from Zabbix API to make it more efficient and filter-aware. Message generation for Telegram bot was refactored and decoupled from data retrieval logic to improve structure, readability, and reuse.

Signed-off-by: UdoChudo <stream@udochudo.ru>
2025-06-17 23:44:30 +05:00

24 lines
1.0 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from telebot.types import InlineKeyboardMarkup, InlineKeyboardButton
def create_groups_keyboard(groups, region_id):
"""
Формирует InlineKeyboardMarkup для выбора группы хостов.
:param groups: список словарей с группами, у каждой есть 'name' и 'groupid'
:param region_id: id региона, нужен для callback_data кнопки "Все группы региона"
:return: telebot.types.InlineKeyboardMarkup
"""
markup = InlineKeyboardMarkup()
for group in groups:
markup.add(InlineKeyboardButton(
text=group['name'],
callback_data=f"group_{group['groupid']}"
))
markup.add(InlineKeyboardButton(
text="Все группы региона\n(Долгое выполнение)",
callback_data=f"all_groups_{region_id}"
))
cancel_button = InlineKeyboardButton("Отмена", callback_data="cancel_input")
markup.add(cancel_button)
return markup