def yes_no_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 1
    markup.one_time_keyboard=True
    markup.add(InlineKeyboardButton("Так", callback_data="answer_yes"),
                InlineKeyboardButton("Ні", callback_data="answer_no"))
    return markup
Exemple #2
0
 def create_inline_kb(
     cls,
     actions: List[Dict[str, Union[str, bool, Tuple[Dict[str, str],
                                                    CallbackData], ], ]],
     schema: List[int],
 ) -> InlineKeyboardMarkup:
     kb = InlineKeyboardMarkup()
     kb.row_width = max(schema)
     buttons = []
     for a in actions:
         data: Dict[str, Union[str, bool, Tuple[Dict[str, str],
                                                CallbackData], ], ] = {}
         for k, v in cls.aliases.items():
             if k in a:
                 a[v] = a[k]
                 del a[k]
         for k in a:
             if k in cls.available_properities["inline"]:
                 data[k] = a[k]
             else:
                 break
         if "callback_data" in data:
             data["callback_data"] = data["callback_data"][1].new(
                 **data["callback_data"][0])
         if "pay" in data:
             if len(buttons) != 0 and data["pay"]:
                 raise ValueError(
                     "Платежная кнопка должна идти первой в клавиатуре")
             data["pay"] = a["pay"]
         buttons.append(InlineKeyboardButton(**data))
     kb.inline_keyboard = create_keyboard_layout(buttons, schema)
     return kb
    def generate_keyboard(self,
                          actions: List[Dict[str,
                                             Union[str, bool,
                                                   Tuple[Dict[str, str],
                                                         CallbackData],
                                                   LoginUrl, CallbackGame]]],
                          schema: List[int]) -> InlineKeyboardMarkup:
        markup = InlineKeyboardMarkup()
        markup.row_width = max(schema)
        buttons = list()
        for action in actions:
            self._replace_aliases(action)
            button_data = self._check_properties(action)

            if 'callback_data' in button_data:
                self._set_callback_data(button_data)

            if 'pay' in button_data:
                if len(buttons) != 0 and button_data['pay']:
                    raise ValueError(
                        'pay type of button must always be the first button in the first row'
                    )
                button_data['pay'] = action['pay']

            if len(button_data) != self.properties_amount:
                raise ValueError('Insufficient data to create a button')

            buttons.append(InlineKeyboardButton(**button_data))
        markup.inline_keyboard = self.create_keyboard_layout(buttons, schema)
        return markup
def add_reminder_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 1
    markup.one_time_keyboard=True
    markup.add(InlineKeyboardButton("Добавити повторююче нагадування", callback_data="add_reminder_simple"),
                InlineKeyboardButton("Добавити повторююче нагадування з данними", callback_data="add_reminder_with_bd"))
    return markup
def show_stat_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 2
    markup.one_time_keyboard=True
    markup.add(InlineKeyboardButton("Графік за певний період", callback_data="graf_some_period"),
                InlineKeyboardButton("Статистика за весь час", callback_data="stat_all_time"),
                InlineKeyboardButton("Аналіз за весь час", callback_data="analyze_stat"))
    return markup
def show_reminders_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 2
    markup.one_time_keyboard=True
    markup.add(InlineKeyboardButton("Показати всі нагадування", callback_data="show_all_reminders"),
                InlineKeyboardButton("Показати нагадування прості", callback_data="show_simple_reminders"),
                InlineKeyboardButton("Показати продвінуті нагадування", callback_data="show_adv_reminders"))
    return markup
def controll_reminder_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 2
    markup.one_time_keyboard=True
    markup.add(InlineKeyboardButton("Видалити нагадування", callback_data="delete_reminder"),
                InlineKeyboardButton("Призупинити нагадування", callback_data="freeze_reminder"),
                InlineKeyboardButton("Редагувати нагадування", callback_data="edit_reminder"))
    return markup
def edit_reminder_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 2
    markup.one_time_keyboard=True
    markup.add(InlineKeyboardButton("Змінити назву нагадування", callback_data="edit_name"),
                InlineKeyboardButton("Змінити назву нагадування", callback_data="edit_description"),
                InlineKeyboardButton("Змінити частоту нагадування", callback_data="edit_periodicity"),
                InlineKeyboardButton("Змінити період перериву", callback_data="edit_break_time"))
    return markup
def menu_markup():
    markup = InlineKeyboardMarkup()
    markup.row_width = 2
    markup.one_time_keyboard=True
    markup.add(InlineKeyboardButton("Добавити напоминання", callback_data="add_reminder"),
                InlineKeyboardButton("Керувати нагадуваннями", callback_data="controll_reminder"),
                InlineKeyboardButton("Показати статистику", callback_data="show_stat"),
                InlineKeyboardButton("Показати мої нагадування", callback_data="show_reminders"),
                InlineKeyboardButton("Інше", callback_data="other"))
    return markup
Exemple #10
0
def arrange_inline_schema(buttons: List[InlineKeyboardButton],
                          count: List[int]) -> InlineKeyboardMarkup:
    kb = InlineKeyboardMarkup()
    kb.row_width = max(count)
    if sum(count) != len(buttons):
        raise ValueError('Количество кнопок не совпадает со схемой')
    tmplist = []
    for a in count:
        tmplist.append([])
        for _ in range(a):
            tmplist[-1].append(buttons.pop(0))
    kb.inline_keyboard = tmplist
    return kb
async def get_burn_user_menu(user_id: int):
    burn_user_menu = InlineKeyboardMarkup(row_width=2)
    burn_user_menu.row_width = 2

    connected_users = await db.get_connected_users(user_id)

    for connected_user in connected_users:
        burn_user_menu.insert(
            InlineKeyboardButton("{}🔥".format(connected_user["full_name"]),
                                 callback_data=burn_user_menu_callback.new(
                                     friend_id=connected_user["id"],
                                     username=connected_user["username"],
                                     full_name=connected_user["full_name"])))

    return burn_user_menu
Exemple #12
0
def get_keyboard(user_id: int) -> InlineKeyboardMarkup:
    kb = InlineKeyboardMarkup()
    kb.row_width = 5
    answers = list(range(5))

    random.shuffle(answers)

    buttons = []

    for answer in answers:
        buttons.append(
            InlineKeyboardButton(text=answer,
                                 callback_data=f'{user_id}:{answer}'))
    kb.add(*buttons)

    return kb
Exemple #13
0
 async def start_button(user: User) -> InlineKeyboardMarkup:
     """Генерирует клавиатуру для команды /start"""
     keyboard = InlineKeyboardMarkup()
     buttons = []
     if (user.subscribe_end == True):
         buttons.append(InlineKeyboardButton(get_text_but(user,'subscribe_continue_pay'), callback_data='subscribe_continue_pay'))
     for key, value in get_text_but(user, 'start_menu').items():
         but = InlineKeyboardButton(value, callback_data=f"start_menu_{key}")
         if (key == 'admin') and (not user.is_admin):
             continue
         buttons.append(but)
     buttons.append(InlineKeyboardButton(text="Расписание", callback_data="start_menu_schedule"))
     if (user.is_have_subscription):
         channels = await UserGeneratorKeyboard.get_user_channel(user)
         for but in channels:
             buttons.append(but)
     buttons.append(InlineKeyboardButton(get_text_but(user, 'register_contact'), callback_data="call_manager", url=get_text_but(user, 'register_contact_url')))
     keyboard.row_width = 1
     keyboard.add(*buttons)
     # keyboard.row(*buttons)
     return keyboard
Exemple #14
0
 def _create_kb(actions: List[Dict[str,
                                   Union[str, bool, Tuple[Dict[str, str],
                                                          CallbackData],
                                         LoginUrl, CallbackGame]]],
                schema: List[int]) -> InlineKeyboardMarkup:
     kb = InlineKeyboardMarkup()
     kb.row_width = max(schema)
     btns = []
     # noinspection DuplicatedCode
     for a in actions:
         data: Dict[str, Union[str, bool, Tuple[Dict[str, str],
                                                CallbackData], LoginUrl,
                               CallbackGame]] = {}
         for k, v in InlineConstructor.aliases.items():
             if k in a:
                 a[v] = a[k]
                 del a[k]
         for k in a:
             if k in InlineConstructor.available_properities:
                 if len(data) < InlineConstructor.properties_amount:
                     data[k] = a[k]
                 else:
                     break
         if 'callback_data' in data:
             data['callback_data'] = data['callback_data'][1].new(
                 **data['callback_data'][0])
         if 'pay' in data:
             if len(btns) != 0 and data['pay']:
                 raise ValueError(
                     'Платежная кнопка должна идти первой в клавиатуре')
             data['pay'] = a['pay']
         if len(data) != InlineConstructor.properties_amount:
             raise ValueError('Недостаточно данных для создания кнопки')
         btns.append(InlineKeyboardButton(**data))
     kb.inline_keyboard = schema_generator.create_keyboard_layout(
         btns, schema)
     return kb