bot Module

Methods for the bot functionality.

bot.ADMIN: int = 1234567890

Chat ID of the admin as read from bot.ini.

Type

int

bot.COLOR: Tuple[int, int, int] = (46, 55, 46)

Text color for the stickers as RGB value.

Type

tuple(int, int, int)

bot.FONT: str = 'stickers/Rotis-SemiSerif-Std-Bold.ttf'

Path of the stickers font.

Type

str

bot.FONT_SIZE: int = 73

Default font size.

Type

int

bot.HOMEPAGE: str = 'https://hirschheissich.gitlab.io/praedikat-besonders-bottig/'

Homepage of this bot.

Type

str

bot.STICKERS_DIR: str = 'stickers'

The directory, where the stickers are stored.

Type

str

bot.STICKER_SET_NAME: str = 'StickerGenerationSet'

The name of the sticker set used to generate the sticker as read from bot.ini.

Type

str

bot.TEMPLATE: str = 'stickers/template.png'

Path of the stickers template.

Type

str

bot.build_sticker_set_name(bot)

Builds the sticker set name given by STICKER_SET_NAME for the given bot.

Parameters

bot (Bot) – The Bot owning the sticker set.

Return type

str

Returns

str

bot.clean_sticker_set(bot)

Cleans up the sticker set, i.e. deletes all but the first sticker.

Parameters

bot (Bot) – The bot.

Return type

None

bot.error(update, context)

Informs the originator of the update that an error occured and forwards the traceback to the admin.

Parameters
  • update (Update) – The Telegram update.

  • context (CallbackContext) – The callback context as provided by the dispatcher.

bot.get_sticker_id(predicate, context)

Gives the sticker ID for the the requested sticker. If it was already build, just reads it from bot_data. Builds a new sticker, otherwise.

Parameters
  • predicate (str) – The text to add to the template.

  • context (CallbackContext) – The callback context as provided by the dispatcher.

Return type

str

bot.get_sticker_set(bot, name)

Get’s the sticker set and creates it, if needed.

Parameters
  • bot (Bot) – The Bot owning the sticker set.

  • name (str) – The name of the sticker set.

Return type

StickerSet

Returns

StickerSet

bot.info(update, context)

Returns some info about the bot.

Parameters
  • update (Update) – The Telegram update.

  • context (CallbackContext) – The callback context as provided by the dispatcher.

Return type

None

bot.inline(update, context)

Answers an inline query by providing the requested sticker.

Parameters
  • update (Update) – The Telegram update.

  • context (CallbackContext) – The callback context as provided by the dispatcher.

bot.message(update, context)

Answers a text message by providing the requested sticker.

Parameters
  • update (Update) – The Telegram update.

  • context (CallbackContext) – The callback context as provided by the dispatcher.

bot.register_dispatcher(disptacher)

Adds handlers and sets up jobs. Convenience method to avoid doing that all in the main script.

Parameters

disptacher (Dispatcher) – The telegram.ext.Dispatcher.

Return type

None