Openbot ID — Python-библиотека
Релиз 1.1.0. Библиотека проверяет права пользователей Telegram через защищённый Openbot ID API. База пользователей хранится только на сервере.
Лицензия: MIT. Автор: Kafnik.
Установка из исходной папки
python -m pip install .
Используй виртуальное окружение (python3 -m venv venv).
С pyTelegramBotAPI
import os
import telebot
from openbot_id import OpenbotID
bot = telebot.TeleBot(os.environ["TELEGRAM_BOT_TOKEN"])
openbot = OpenbotID(api_key=os.environ["OPENBOT_API_KEY"], bot=bot)
@bot.message_handler(commands=["test"])
@openbot.check_level("tester", level=2)
def test(message):
bot.reply_to(message, "✅ Доступ разрешён")
@bot.message_handler(commands=["panel"])
@openbot.require_access()
def panel(message):
bot.reply_to(message, "Панель доступна")
# Несколько декораторов check_level означают ИЛИ:
@bot.message_handler(commands=["staff"])
@openbot.check_level("tester", level=2)
@openbot.check_level("developer", level=2)
def staff(message):
bot.reply_to(message, "✅ Вы тестировщик или разработчик уровня 2+")
bot.infinity_polling()
Декоратор @bot.message_handler должен стоять выше @openbot.check_level и @openbot.require_access.
Другие функции
openbot.get_user(123456789) # словарь с user_id, exists, status, level
openbot.get_status(123456789) # статус
openbot.get_level(123456789) # числовой уровень
openbot.has_level(123456789, "tester", 2) # bool
openbot.check_access(123456789) # bool
При отсутствии доступа команда не выполняется. Если API недоступен, проверка также не пропускает команду. При переданном bot=bot библиотека отвечает пользователю сообщением.
Сервер по умолчанию: https://server.tail116c85.ts.net. При смене сервера можно передать api_url="https://...".
Безопасность
- Выдавай разработчикам только их собственные ключи
ob_live_.... - Не публикуй главный секрет сервера, токены ботов или SQLite-базу.
- Для реального бота храни секреты в переменных окружения.
- Библиотека требует HTTPS.
- При отключении домашнего интернета API временно недоступен.
Совпадение имён
На Linux-сервере есть локальный openbot_id.py, который управляет SQLite. Не устанавливай клиентский пакет в то же Python-окружение, пока серверный модуль не переименован или не вынесен в отдельный пакет.
Тесты
python -m unittest discover -s tests -v
Metadata
Release files for openbot-id 1.1.0
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 |
|---|---|---|---|---|
| openbot_id-1.1.0.tar.gz | 6.4 kB | Without provenance | Details for openbot_id-1.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| openbot_id-1.1.0-py3-none-any.whl | Python 3 | none | any | Details for openbot_id-1.1.0-py3-none-any.whl |
Total release size: 12.2 kB
Release files / openbot_id-1.1.0.tar.gz
| Download URL | openbot_id-1.1.0.tar.gz |
|---|---|
| Size | 6.4 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
0ffab30c5587e85d5c73f70625d939986fe8b90fc6e771c65372eeda58d307d9
|
|
BLAKE2b-256 checksum How to use checksums |
9db38ad3d88ce726453f38d4e6e70baa6fbb9a72cf22a56a0f47d39cdd178e7a
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|
Release files / openbot_id-1.1.0-py3-none-any.whl
| Download URL | openbot_id-1.1.0-py3-none-any.whl |
|---|---|
| Size | 5.8 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ca40c12665951e5f258c7420fd585ed904cddc322752f1ad21d2900afec8e2b9
|
|
BLAKE2b-256 checksum How to use checksums |
db376980d1e4013fbd0f4bae48078ff07b6f8572cfdde4f36e389833749885b7
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.13.7
|
Security for openbot-id 1.1.0
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.