This release is a pre-release and may not be stable for production use.
ubits-bot
Асинхронная Python-библиотека для Ubits Bot API. Python 3.10+.
Bot API пока не включён на ubits.org. SDK и пример готовы; запросы начнут работать после активации API на сервере.
Установка
python -m pip install --pre ubits-bot
Для установки бета-версии нужен флаг --pre.
Пример
Создайте бота через @CreateBot: /newbot. Сохраните выданный токен в переменную
окружения UBITS_BOT_TOKEN.
import asyncio
import os
from ubits_bot import Bot
async def main():
async with Bot(os.environ["UBITS_BOT_TOKEN"]) as bot:
async def handle(update):
message = update.get("message")
if update["type"] == "message" and message and message["kind"] == "text":
await bot.send_message(message["chatId"], "Привет!")
await bot.run_polling(handle)
asyncio.run(main())
Программа должна оставаться запущенной. Один процесс polling на токен. Пользователь сначала сам открывает диалог с ботом в Ubits.
Методы
get_me,get_user,get_chat,get_messagesend_message,edit_message,delete_messagesend_media,edit_mediadownload_file,download_user_photoget_updates,run_polling
Документация API · OpenAPI · Игровой бот
run_polling сохраняет offset после обработки всей пачки событий. Повторная обработка события возможна: учитывайте updateId в своём коде. SDK автоматически повторяет чтение при транспортных ошибках, 429 и 5xx. Отправка и загрузка файлов автоматически не повторяются. Для повторной отправки текста используйте заранее сохранённый message_id.
Разработка
python -m pip install -e .
python -m unittest discover -s tests -v
Лицензия MIT.
Metadata
Release files for ubits-bot 0.1.0b2
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 |
|---|---|---|---|---|
| ubits_bot-0.1.0b2.tar.gz | 17.1 kB | Without provenance | Details for ubits_bot-0.1.0b2.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| ubits_bot-0.1.0b2-py3-none-any.whl | Python 3 | none | any | Details for ubits_bot-0.1.0b2-py3-none-any.whl |
Total release size: 23.2 kB
Release files / ubits_bot-0.1.0b2.tar.gz
| Download URL | ubits_bot-0.1.0b2.tar.gz |
|---|---|
| Size | 17.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1eb6484a961e8763db510bf24de5bb32f15c30acd7139d72c8eaf7c2a5fae58a
|
|
BLAKE2b-256 checksum How to use checksums |
ffd79fcc2a6f547d20fba27c7508855010700713192a0130acf330e12b132ba2
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.9
|
Release files / ubits_bot-0.1.0b2-py3-none-any.whl
| Download URL | ubits_bot-0.1.0b2-py3-none-any.whl |
|---|---|
| Size | 6.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
8f6546e34db0826e8b70faa55f198c6483fba138285f90b7df0f04ff8e8654b8
|
|
BLAKE2b-256 checksum How to use checksums |
59128fdae3ffb888f878e558ae544aa5d4585aeb910f183745e7c6b3f64e1629
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.10.9
|
Security for ubits-bot 0.1.0b2
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.