Skip to main content

Python framework for Bale messenger Bot API

Project description

Bale bot python

Build Status

Python SDK and samples for Bale bot messenger.

Register for an Access Token

You'll need to create your bot by @Bot_Father. Bot_Father gives you a Token to start.


pip install -r requirements.txt


import asyncio

from balebot.filters import *
from balebot.handlers import MessageHandler, CommandHandler
from balebot.models.messages import *
from balebot.updater import Updater

updater = Updater(token="Bot_token",
bot =
dispatcher = updater.dispatcher

Note: You need to set if you want to use the logger class

Simple communication with client

Allows you to hear from client and answer.

@dispatcher.message_handler(filters=TextFilter(keywords=["hello"]))  # filter text the client enter to bot
def hear(bot, update):
    message = TextMessage('Hello')
    user_peer = update.get_effective_user()
    bot.send_message(message, user_peer, success_callback=success, failure_callback=failure)
Sending a simple voice message:

Note:You should upload the voice file first.

Allows you to send a voice message. (You can also send a document in the same way).

def send_voice(bot, update):
    user_peer = update.get_effective_user()
    v_message = VoiceMessage(file_id=file_id, access_hash=access_hash, name="Hello", file_size='259969',
                                 duration=20, file_storage_version=1)
    bot.send_message(v_message, user_peer, success_callback=success, failure_callback=failure)
Sending a generic template message:

Note:Generic Template Messages

Allows you to add cool text buttons to a general message.

def ask_question(bot, update):
    general_message = TextMessage("a message")
    btn_list = [TemplateMessageButton(text="yes", value="yes", action=0),
                TemplateMessageButton(text="no", value="no", action=0)]
    template_message = TemplateMessage(general_message=general_message, btn_list=btn_list)
    bot.send_message(template_message, user_peer, success_callback=success, failure_callback=failure)
Sending a generic purchase message:

Allows you send a purchase message. Clients can pay the money requested by the message by pressing "pay" button.

def purchase_message(bot, update):
    message = update.get_effective_message()
    user_peer = update.get_effective_user()
    first_purchase_message = PurchaseMessage(msg=message, account_number=6037991067471130, amount=10,
    bot.send_message(first_purchase_message, user_peer, success_callback=success, failure_callback=failure)

visit bale-developers for more information


Build Status

[1.7.14] - 2019-03-02


  • exact_keywords argument to text_filter and template_response_filter
  • termination signal handling
  • sengin to channel by nickName


  • code examples
  • base_url added to updater arguments
  • set default group shield to off

[1.6.12] - 2019-01-08


  • get_quoted_message and get_quoted_sender_peer_id to FatSeqUpdate for getting replied and forwarded messages
  • default photo and message type limitation for purchase message
  • get_receipt function to BankMessage for getting receipt info as a named tuple
  • get_receipt and get_quoted_message examples


  • filters problem
  • handle monitoring hash function problem
  • some code examples

[1.5.11] - 2019-01-03


  • added validator parameter to filters as a callable function to validate the inputs
  • added text field among with text_message filed to template response message for unifying with other classes text field


  • state holder problem at stop

[1.4.10] - 2018-12-23


  • Quoted Message Handler
  • default action and value for template_message_button
  • group_shield to config for preventing bot to handle updates from group_peer
  • saving bot state_machine to redis db through state_holder and redis configs in config
  • template_message, location_message and contact_message load_from_json


  • bot.send_document

[1.3.9] - 2018-12-05


  • get_response method in response class
  • IPG payment message
  • healthy socket connection

[1.2.8] - 2018-09-30


  • Send photo message easier than the past.
  • Send Document message easier than the past.


  • network connection

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

balebot-1.8.15.tar.gz (35.0 kB view hashes)

Uploaded Source

Built Distribution

balebot-1.8.15-py3-none-any.whl (89.8 kB view hashes)

Uploaded Python 3

Supported by

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