Metadata-Version: 2.1
Name: LeBotTel
Version: 0.4.1
Author: Antonio Vidos, Tobias Lettner, Tobias Weiß, Uwe Kölbl
Author-email: lebottel.team@gmail.com
License: MIT License
        
        Copyright (c) 2023 tobiweisss
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.10.0
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: requests~=2.31.0
Provides-Extra: test
Requires-Dist: pytest~=7.4.3; extra == "test"
Requires-Dist: requests_mock~=1.11.0; extra == "test"
Provides-Extra: lint
Requires-Dist: flake8~=6.1.0; extra == "lint"
Requires-Dist: black~=23.11.0; extra == "lint"
Requires-Dist: ruff==0.7.4; extra == "lint"
Requires-Dist: mypy==1.13.0; extra == "lint"
Provides-Extra: dev
Requires-Dist: LeBotTel[lint,test]; extra == "dev"

![Logo](https://raw.githubusercontent.com/tobiweisss/LeBotTel/main/images/logo_text_inv.png#gh-dark-mode-only)
![Logo](https://raw.githubusercontent.com/tobiweisss/LeBotTel/main/images/logo_text.png#gh-light-mode-only)
## 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](#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

```bash
pip install LeBotTel
```

#### Send a message

```python
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
```

<b>Hint:</b> 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

```python
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

```python
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
