Bale bot python
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.
Installation
pip install -r requirements.txt
Usage
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",
loop=asyncio.get_event_loop())
bot = updater.bot
dispatcher = updater.dispatcher
Note: You need to set Config.py 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',
mime_type="audio/mpeg",
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.
@dispatcher.message_handler(PhotoFilter())
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,
money_request_type=MoneyRequestType.normal)
bot.send_message(first_purchase_message, user_peer, success_callback=success, failure_callback=failure)
dispatcher.finish_conversation(update)
visit bale-developers for more information
Changelog
[1.7.14] - 2019-03-02
Added
- exact_keywords argument to text_filter and template_response_filter
- termination signal handling
- sengin to channel by nickName
fixed
- code examples
- base_url added to updater arguments
- set default group shield to off
[1.6.12] - 2019-01-08
Added
- 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
fixed
- filters problem
- handle monitoring hash function problem
- some code examples
[1.5.11] - 2019-01-03
Added
- 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
fixed
- state holder problem at stop
[1.4.10] - 2018-12-23
Added
- 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
fixed
- bot.send_document
[1.3.9] - 2018-12-05
Added
- get_response method in response class
- IPG payment message
- healthy socket connection
[1.2.8] - 2018-09-30
Added
- Send photo message easier than the past.
- Send Document message easier than the past.
fixed
- network connection
Metadata
Release files for balebot 1.8.15
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| balebot-1.8.15.tar.gz | 35.0 kB | Without provenance | Details for balebot-1.8.15.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| balebot-1.8.15-py3-none-any.whl | Python 3 | none | any | Details for balebot-1.8.15-py3-none-any.whl |
Total release size: 124.8 kB
Release files / balebot-1.8.15.tar.gz
| Download URL | balebot-1.8.15.tar.gz |
|---|---|
| Size | 35.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
4890e3fcf9aac98a5afb297793aebf83e1a64f14fc9e02c593b866b1935714d1
|
|
BLAKE2b-256 checksum How to use checksums |
cea9d9d3add3403a100f02072dff89b93f0699108215b1f8bc1d598c446429dc
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.22.0 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.5.2
|
Release files / balebot-1.8.15-py3-none-any.whl
| Download URL | balebot-1.8.15-py3-none-any.whl |
|---|---|
| Size | 89.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
436d33feba861b6ca341f8683832cb013275737c78dc594083b95989669a75f4
|
|
BLAKE2b-256 checksum How to use checksums |
5add41698e1f7f55cf7ccff0c6e9e511b3f3cdf011022dae0f5ac103649dda12
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/1.11.0 pkginfo/1.4.2 requests/2.22.0 setuptools/40.0.0 requests-toolbelt/0.8.0 tqdm/4.19.5 CPython/3.5.2
|
Security for balebot 1.8.15
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.