bot Module¶
Methods for the bot functionality.
-
bot.
HOMEPAGE
: str = 'https://hirschheissich.gitlab.io/image-2-sticker-bot/' Homepage of this bot.
- Type
-
bot.
STICKER_SET_NAME
: str = 'StickerGenerationSet' The name of the sticker set used to generate the sticker as read from
bot.ini
.- Type
-
bot.
build_and_reply
(file_id: str, message: telegram.message.Message) → None Builds the requested sticker from a image specified by the
file_id
and sends it back as reply to themessage
. If the file is to large to handle, this will inform the user.- Parameters
file_id – File id of the image to handle.
message – The message to reply to.
-
bot.
build_sticker_set_name
(bot: telegram.bot.Bot) → str Builds the sticker set name given by
STICKER_SET_NAME
for the given bot.- Parameters
bot – The Bot owning the sticker set.
- Returns
str
-
bot.
clean_sticker_set
(bot: telegram.bot.Bot) → None Cleans up the sticker set, i.e. deletes all but the first sticker.
- Parameters
bot – The bot.
-
bot.
default_message
(update: telegram.update.Update, context: telegram.ext.callbackcontext.CallbackContext) → None Answers any message with a note that it could not be parsed.
- Parameters
update – The Telegram update.
context – The callback context as provided by the dispatcher.
-
bot.
document_message
(update: telegram.update.Update, context: telegram.ext.callbackcontext.CallbackContext) → None Answers a file message by providing the requested sticker.
- Parameters
update – The Telegram update.
context – The callback context as provided by the dispatcher.
-
bot.
error
(update: telegram.update.Update, context: telegram.ext.callbackcontext.CallbackContext) → None Informs the originator of the update that an error occured and forwards the traceback to the admin.
- Parameters
update – The Telegram update.
context – The callback context as provided by the dispatcher.
-
bot.
get_sticker_set
(bot: telegram.bot.Bot, name: str) → telegram.files.sticker.StickerSet Get’s the sticker set and creates it, if needed.
- Parameters
bot – The Bot owning the sticker set.
name – The name of the sticker set.
- Returns
StickerSet
-
bot.
info
(update: telegram.update.Update, context: telegram.ext.callbackcontext.CallbackContext) → None Returns some info about the bot.
- Parameters
update – The Telegram update.
context – The callback context as provided by the dispatcher.
-
bot.
photo_message
(update: telegram.update.Update, context: telegram.ext.callbackcontext.CallbackContext) → None Answers a photo message by providing the requested sticker.
- Parameters
update – The Telegram update.
context – The callback context as provided by the dispatcher.
-
bot.
register_dispatcher
(disptacher: telegram.ext.dispatcher.Dispatcher) → None Adds handlers. Convenience method to avoid doing that all in the main script.
- Parameters
disptacher – The
telegram.ext.Dispatcher
.
-
bot.
scale_image
(image: IO, outfile: IO) → None Scales an image such that it fits into a 512×512 px square.
- Parameters
image – The image to scale as open file handle.
outfile – The file to write to as open file handle.