Skip to main content

No project description provided

Project description

Logo Logo

Abstract

LeBotTel is an easy to use python package to create your own Telegram bots for different use cases. For details how to use this package refer to the quick start section.

Name

The name LeBotTel is combined from "LeCun", "RoBot" and "Telegram". The "Le" in the name comes from Yann LeCun, to honor his work on neural networks (has nothing to do with this project, but he is a great scientist and pioneer in the field of neural networks (LeNet)). What has this bot to do with neural networks? We want to use this bot to log the training of neural networks. "Bot" comes from RoBot, because this is what the goal of this project is. And "Tel" comes from Telegram, because its a bot for Telegram. The "Pi" in our logo represents looks similar to the "tT" in "LeBotTel" and stands for the used Programming Language Python.

Quick Start

Installation

pip install LeBotTel

Send a message

from LeBotTel import BaseTelegramBot

bot = BaseTelegramBot(token="YOUR_BOT_TOKEN", chat_id="YOUR_CHAT_ID")

bot.send_message("Hello World!") # Raises ChatIdError if chat_id is not set

Hint: To get the chat_id you first have to send your Bot a message (e.g. /start). Then you need to send a GET request to the following URL:

https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates

In the returned JSON you will find the chat_id under message->chat->id.

Send an image

from LeBotTel.base_telegram_bot import BaseTelegramBot
import imageio
import io

bot = BaseTelegramBot(token="YOUR_BOT_TOKEN", chat_id="YOUR_CHAT_ID")

buffer = io.BytesIO()
img = imageio.imread('PATH_TO_IMAGE') # Image has to be in *.png format
imageio.imsave(buffer, img, format="PNG")

bot.send_image(buffer.getvalue()) # Raises ChatIdError if chat_id is not set

Send a gif

from LeBotTel.base_telegram_bot import BaseTelegramBot
import imageio
import io
import glob

bot = BaseTelegramBot(token="YOUR_BOT_TOKEN", chat_id="YOUR_CHAT_ID")

buffer = io.BytesIO()
images = []
image_files = glob.glob('PATH_TO_IMAGES_DIR/*.png') # Images have to be in *.png format

for image_file in image_files:
    images.append(imageio.imread(image_file))

imageio.mimsave(buffer, images, format="GIF", duration=30)

bot.send_gif(buffer.getvalue()) # Raises ChatIdError if chat_id is not set

Changelog

  • 0.1.0: setup package. Bot can send messages and images
  • 0.2.0: Bot can receive messages
  • 0.3.0: Add method export_config to save the current token and chat_id to a file, add classmethod from_config to create a bot from the config file, add classmethod from_env to create a bot from the environment variables TELEGRAM_BOT_TOKEN and TELEGRAM_CHAT_ID. Methods import_chat_id and export_chat_id are deprecated and will be removed in version 1.0.0
  • 0.3.1: Adapting package structure
  • 0.4.0: Add send_gif method
  • 0.4.1: Switch to pyproject.toml for build
  • 0.4.2: Use ruff for linting in CI-pipeline

Authors

  • Antonio Vidos
  • Tobias Lettner
  • Tobias Weiß
  • Uwe Kölbel

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

lebottel-0.4.2.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

LeBotTel-0.4.2-py3-none-any.whl (7.5 kB view details)

Uploaded Python 3

File details

Details for the file lebottel-0.4.2.tar.gz.

File metadata

  • Download URL: lebottel-0.4.2.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for lebottel-0.4.2.tar.gz
Algorithm Hash digest
SHA256 d785ff16924ad09fcd89c0ac64be51d7db9c7b201fb818767d3787db73fcb0ad
MD5 9615e1e300a9fc9e31eec02e2c6952b4
BLAKE2b-256 4701a65e7af8f188da1a257dcadc724809030cc1cf52094b7280aa99598227ef

See more details on using hashes here.

Provenance

The following attestation bundles were made for lebottel-0.4.2.tar.gz:

Publisher: push_release_to_pypi.yml on tobiweisss/LeBotTel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file LeBotTel-0.4.2-py3-none-any.whl.

File metadata

  • Download URL: LeBotTel-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 7.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for LeBotTel-0.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e3118ac9eb352891243e1dde956ac950b856d5326129af5326dc9de1e2591255
MD5 218cbd7191427377c7ea662c2f4eb6f3
BLAKE2b-256 d625aaff02ba134b43f4821820624349c878232562cb1d1f9ea3ce4f93033a5a

See more details on using hashes here.

Provenance

The following attestation bundles were made for LeBotTel-0.4.2-py3-none-any.whl:

Publisher: push_release_to_pypi.yml on tobiweisss/LeBotTel

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page