bot.keyboards Module¶
This module contains functions for generating often needed keyboards.
- bot.keyboards.BACK = 'Zurück'¶
Text indicating a ‘back’ action. Use as text or callback data.
- Type
- bot.keyboards.CHANNEL_KEYBOARD = <telegram.inline.inlinekeyboardmarkup.InlineKeyboardMarkup object>¶
Keyboard leading to the info channel and the docs.
- bot.keyboards.DOCS_KEYBOARD = <telegram.inline.inlinekeyboardmarkup.InlineKeyboardMarkup object>¶
Keyboard leading to the docs.
- bot.keyboards.DONE = 'Fertig'¶
Text indicating a ‘done’ action. Use as text or callback data.
- Type
- bot.keyboards.REGISTRATION_KEYBOARD = <telegram.inline.inlinekeyboardmarkup.InlineKeyboardMarkup object>¶
Keyboard that triggers the registration process.
- bot.keyboards.build_instruments_keyboard(current_selection=None)¶
Builds a
telegram.InlineKeyboardMarkup
listing all instruments that are up for selection. The callback data for each button will equal its text. Also appends a button with the textDONE
and dataDONE
at the very end of the keyboard.- Parameters
current_selection (
Optional
[Dict
[Instrument
,bool
]]) – Optional. If passed, gives the current selection and the keyboard will reflect that selection state. If not present, all instruments will be deselected. A corresponding dictionary is returned e.g. byparse_instruments_keyboard()
.- Return type
InlineKeyboardMarkup
- Returns
InlineKeyboardMarkup
- bot.keyboards.build_questions_hints_keyboard(orchestra, question=False, hint=False, current_selection=None, multiple_choice=True, allowed_hints=None, exclude_members=None)¶
Builds a
telegram.InlineKeyboardMarkup
listing all questions that are up for selection for the given orchestra. The callback data for each button will equal its text. Also appends a button with the textDONE
and dataDONE
at the very end of the keyboard.- Parameters
orchestra (
Orchestra
) – The orchestra to build the keyboard for.question (
bool
) – Optional. Set toTrue
, if the keyboard is build for question selection.hint (
bool
) – Optional. Set toTrue
, if the keyboard is build for hint selection.current_selection (
Optional
[Dict
[str
,bool
]]) – Optional. If passed, gives the current selection and the keyboard will reflect that selection state. If not present, all options will be deselected. A corresponding dictionary is returned e.g. byparse_questions_hints_keyboard()
.multiple_choice (
bool
) – Optional. Whether the questions are supposed to be multiple choice or free text. Defaults toTrue
.allowed_hints (
Optional
[List
[str
]]) – Optional. Only relevant ifquestion
isTrue
. If passed, in this case only question attributes which are questionable for at least one of the allowed hints will be listed in the keyboard.exclude_members (
Optional
[Iterable
[Member
]]) – Optional. Members to exclude from serving as hint.
Note
Exactly one on
hint
andquestion
must beTrue
.- Return type
InlineKeyboardMarkup
- Returns
InlineKeyboardMarkup
- Raises
RuntimeError – If the orchestra currently has no questionable attributes.
- bot.keyboards.parse_instruments_keyboard(keyboard)¶
Parses the given keyboard and returns ad dictionary, indicating for every instrument, whether it has been selected or not.
- Parameters
keyboard (
InlineKeyboardMarkup
) – Thetelegram.InlineKeyboardMarkup
from an update. Buttons must have the structure as provided bybuild_instruments_keyboard()
.- Return type
- bot.keyboards.parse_questions_hints_keyboard(keyboard)¶
Parses the given keyboard and returns ad dictionary, indicating for every option, whether it has been selected or not.
- Parameters
keyboard (
InlineKeyboardMarkup
) – Thetelegram.InlineKeyboardMarkup
from an update. Buttons must have the structure as provided bybuild_questions_hints_keyboard()
.- Return type