MCPcopy Create free account
hub / github.com/eternnoir/pyTelegramBotAPI / add

Method add

telebot/types.py:3169–3201  ·  view source on GitHub ↗

This method adds buttons to the keyboard without exceeding row_width. E.g. InlineKeyboardMarkup.add("A", "B", "C") yields the json result: {keyboard: [["A"], ["B"], ["C"]]} when row_width is set to 1. When row_width is set to 2, the result: {keyboard

(self, *args, row_width=None)

Source from the content-addressed store, hash-verified

3167 self.keyboard: List[List[InlineKeyboardButton]] = keyboard or []
3168
3169 def add(self, *args, row_width=None) -> 'InlineKeyboardMarkup':
3170 """
3171 This method adds buttons to the keyboard without exceeding row_width.
3172
3173 E.g. InlineKeyboardMarkup.add("A", "B", "C") yields the json result:
3174 {keyboard: [["A"], ["B"], ["C"]]}
3175 when row_width is set to 1.
3176 When row_width is set to 2, the result:
3177 {keyboard: [["A", "B"], ["C"]]}
3178 See https://core.telegram.org/bots/api#inlinekeyboardmarkup
3179
3180 :param args: Array of InlineKeyboardButton to append to the keyboard
3181 :type args: :obj:`list` of :class:`telebot.types.InlineKeyboardButton`
3182
3183 :param row_width: width of row
3184 :type row_width: :obj:`int`
3185
3186 :return: self, to allow function chaining.
3187 :rtype: :class:`telebot.types.InlineKeyboardMarkup`
3188 """
3189 if row_width is None:
3190 row_width = self.row_width
3191
3192 if row_width > self.max_row_keys:
3193 # Todo: Will be replaced with Exception in future releases
3194 logger.error('Telegram does not support inline keyboard row width over %d.' % self.max_row_keys)
3195 row_width = self.max_row_keys
3196
3197 for row in service_utils.chunks(args, row_width):
3198 button_array = [button for button in row]
3199 self.keyboard.append(button_array)
3200
3201 return self
3202
3203 def row(self, *args) -> 'InlineKeyboardMarkup':
3204 """

Callers 11

test_edit_markupMethod · 0.95
newmemberFunction · 0.95
gen_markupFunction · 0.95
generate_calendar_daysFunction · 0.95
generate_calendar_monthsFunction · 0.95
generate_calendar_daysFunction · 0.95
generate_calendar_monthsFunction · 0.95
rowMethod · 0.95
quick_markupFunction · 0.95

Calls

no outgoing calls