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 is f'Chat-ID {chat_id}'.

Parameters
Returns

The string representation.

Return type

str

bot.utils.iter_tuesdays(from_date, until_date)

Gives an iterator allowing to iterate over the tuesdays from from_date to until_date. Both dates must be tuesdays.

Note

Just like for range(), until_date will be not be included!

Parameters
Return type

typing.Iterator[datetime.date]

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 by telegram.Bot.send_message(). Defaults to True.

Return type

str

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) – If True, the return value may be the same date as the input value. Otherwise the next week is forced. Defaults to True.

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

datetime.date

bot.utils.pprint(date)

Thin wrapper for datetime.date.strftime() to achieve consistent formatting.

Parameters

date (datetime.date) – The date to format.

Return type

str

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) – If True, the return value may be the same date as the input value. Otherwise the next week is forced. Defaults to True.

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.time object localized as bot.utils.TIMEZONE.

Parameters

date (datetime.date) – The date.

Return type

datetime.time

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

bool