Skip to main content

A powerful Python library for developing Bale messenger bots

Project description

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.

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

baleh-0.2.3.tar.gz (10.3 kB view details)

Uploaded Source

Built Distribution

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

baleh-0.2.3-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file baleh-0.2.3.tar.gz.

File metadata

  • Download URL: baleh-0.2.3.tar.gz
  • Upload date:
  • Size: 10.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for baleh-0.2.3.tar.gz
Algorithm Hash digest
SHA256 7ab0b3678c81faa35816be7e719f2ad7d7cdec3b5c4c5864c16d46254a674e66
MD5 8c66fb2338560f5b7abf7ea0ba0e1bdd
BLAKE2b-256 33be288ce138b2126a4d57eac81f7e0308436eb01794370700d24819c8388576

See more details on using hashes here.

File details

Details for the file baleh-0.2.3-py3-none-any.whl.

File metadata

  • Download URL: baleh-0.2.3-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for baleh-0.2.3-py3-none-any.whl
Algorithm Hash digest
SHA256 185fb532ac8223dbc1beeab9b5e391a047ffb456f8e0fd06d1d0f7c40fc7e167
MD5 e963263d87644b7dcc57dc4bb891ca31
BLAKE2b-256 e1d020240b98c0a6e5e1882f02e9a46fc1521653725d7e9df1d168e2479c1296

See more details on using hashes here.

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