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

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.1.tar.gz (9.2 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.1-py3-none-any.whl (7.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: lebottel-0.4.1.tar.gz
  • Upload date:
  • Size: 9.2 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.1.tar.gz
Algorithm Hash digest
SHA256 4ecae902b2645e08152a8fec6eef9a4741833fcb543ea160503472fd7cd4c27c
MD5 bca8f543ac4412faa35b40635a351b8e
BLAKE2b-256 96d373d921047ee93623ff3b83deb6c29a576157b9471edc7f06c0dbd3b23bb7

See more details on using hashes here.

Provenance

The following attestation bundles were made for lebottel-0.4.1.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.1-py3-none-any.whl.

File metadata

  • Download URL: LeBotTel-0.4.1-py3-none-any.whl
  • Upload date:
  • Size: 7.3 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.1-py3-none-any.whl
Algorithm Hash digest
SHA256 91b0d767772e2bab275997c2b321037a524680645206e0d652fbaa6828a0152b
MD5 bf86108c0388457ac04931f172664323
BLAKE2b-256 c22df39aed547a185a0729d089418db4e9f18332b40c9ea9ffe65da0ee1a2a9e

See more details on using hashes here.

Provenance

The following attestation bundles were made for LeBotTel-0.4.1-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