Skip to main content

Baleh

An advanced Python library for Bale messenger bots, inspired by the Telegram Bot API.

Installation

Install the library using pip:

pip install baleh
Prerequisites
This library requires ffmpeg for converting animated stickers (.tgs to .webm). Install it on your system:

Ubuntu/Debian:
bash


sudo apt-get install ffmpeg
MacOS:
bash


brew install ffmpeg
Windows: Download from ffmpeg.org, extract, and add to your PATH.
The library also uses the following Python packages (automatically installed via pip):

aiohttp>=3.8.0
Pillow>=9.0.0
Features
Send text messages, photos, videos, audio, stickers (static and animated), and documents
Manage chats (get chat info, ban/unban members)
Handle incoming messages with decorators
Asynchronous API with aiohttp
Webhook support
Type hints for better IDE support
Retry mechanism for handling API errors
Support for animated stickers (converts .tgs to .webm)
Usage
Send a Message
python


from baleh import BaleClient
import asyncio

async def main():
    client = BaleClient("your_bot_token")
    await client.connect()
    message = await client.send_message(chat_id=123456789, text="Hello, Bale!")
    print(message.text)
    await client.disconnect()

asyncio.run(main())
Send a Photo
python


async def send_photo():
    client = BaleClient("your_bot_token")
    await client.connect()
    message = await client.send_photo(chat_id=123456789, photo="path/to/photo.jpg", caption="My photo")
    await client.disconnect()

asyncio.run(send_photo())
Send an Animated Sticker
The library automatically converts .tgs files to .webm for animated stickers:

python


async def send_animated_sticker():
    client = BaleClient("your_bot_token")
    await client.connect()
    message = await client.send_animation(chat_id=123456789, animation="path/to/sticker.tgs")
    await client.disconnect()

asyncio.run(send_animated_sticker())
Handle Incoming Messages
python


async def handle_messages():
    client = BaleClient("your_bot_token")
    
    @client.on_message()
    async def on_message(message):
        await client.send_message(message.chat.id, f"Received: {message.text}")
    
    await client.connect()
    await client.start_polling()

asyncio.run(handle_messages())
Contributing
Fork the repository at github.com/hamidrashidi98/baleh and submit pull requests. Feel free to open issues for bugs or feature requests.

Development
To contribute to the development of this library:

Clone the repository:
bash


git clone https://github.com/hamidrashidi98/baleh.git
cd baleh
Install dependencies:
bash


pip install -r requirements.txt
Make your changes and test them.
Submit a pull request.
License
This project is licensed under the MIT License - see the LICENSE file for details.

Metadata

Release files for baleh 0.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for baleh 0.2.3
File Size Uploaded
baleh-0.2.3.tar.gz 10.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for baleh 0.2.3
File Interpreter ABI Platform
baleh-0.2.3-py3-none-any.whl Python 3 none any Details

Total release size: 20.5 kB

Release files / baleh-0.2.3.tar.gz

Download URL baleh-0.2.3.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
7ab0b3678c81faa35816be7e719f2ad7d7cdec3b5c4c5864c16d46254a674e66
BLAKE2b-256 checksum
How to use checksums
33be288ce138b2126a4d57eac81f7e0308436eb01794370700d24819c8388576
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release files / baleh-0.2.3-py3-none-any.whl

Download URL baleh-0.2.3-py3-none-any.whl
Size 10.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
185fb532ac8223dbc1beeab9b5e391a047ffb456f8e0fd06d1d0f7c40fc7e167
BLAKE2b-256 checksum
How to use checksums
e1d020240b98c0a6e5e1882f02e9a46fc1521653725d7e9df1d168e2479c1296
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.3

Release history Release notifications | RSS feed

This release

0.2.3 This release

2 release files

0.2.2

2 release files

0.2.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page