bot.utils Module¶
The module contains functionality for changing the order of instrument groups.
- bot.utils.chat2str(chat_id, bot)¶
Given a chat id, returns a string representation of the chat as combination of first name, last name, username and chat title.
In case fetching the chat via
telegram.Bot.get_chat()fails, the output isf'Chat-ID {chat_id}'.- Parameters
chat_id (
typing.Union[str,int]) – The chat id.bot (
telegram.bot.Bot) – The bot.
- Returns
The string representation.
- Return type
- bot.utils.iter_tuesdays(from_date, until_date)¶
Gives an iterator allowing to iterate over the tuesdays from
from_datetountil_date. Both dates must be tuesdays.Note
Just like for
range(),until_datewill be not be included!- Parameters
from_date (
datetime.date) – The start date.until_date (
datetime.date) – The end date.
- Return type
- bot.utils.next_sweep_text(context, html=True)¶
Tells you, whe needs to sweep this week an next.
- Parameters
context (
telegram.ext.callbackcontext.CallbackContext) – The context as provided by the dispatcher.html (
bool) – Whether or not to make the output HTML-formatted as expected bytelegram.Bot.send_message(). Defaults toTrue.
- Return type
- bot.utils.next_tuesday(date, allow_today=True)¶
Gives the date of the tuesday following the given datetime.
- Parameters
date (
datetime.date) – The date to compute the next tuesday for.allow_today (
bool) – IfTrue, the return value may be the same date as the input value. Otherwise the next week is forced. Defaults toTrue.
- Returns
datetime.date: The date of the next tuesday
- Return type
obj
- bot.utils.parse_pprint(date)¶
Reverse operation for
pprint().- Parameters
date (
str) – The date to format.- Return type
- bot.utils.pprint(date)¶
Thin wrapper for
datetime.date.strftime()to achieve consistent formatting.- Parameters
date (
datetime.date) – The date to format.- Return type
- bot.utils.previous_tuesday(date, allow_today=True)¶
Gives the date of the tuesday before the given datetime.
- Parameters
date (
datetime.date) – The date to compute the next tuesday for.allow_today (
bool) – IfTrue, the return value may be the same date as the input value. Otherwise the next week is forced. Defaults toTrue.
- Returns
datetime.date: The date of the previous tuesday
- Return type
obj
- bot.utils.rehearsal_time(date)¶
Gives the rehearsal time (7:30 pm) as
datetime.timeobject localized asbot.utils.TIMEZONE.- Parameters
date (
datetime.date) – The date.- Return type
- bot.utils.str2bool(str_input)¶
Shortcut for converting
str(boolean_input)back to a boolean.- Parameters
str_input (
typing.Literal[‘True’, ‘False’]) – The input.- Return type