Skip to main content

Openbot ID — Python-библиотека

Релиз 1.0.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, "Панель доступна")

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.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for openbot-id 1.0.0
File Size Uploaded Provenance Actions
openbot_id-1.0.0.tar.gz 5.8 kB Without provenance Details for openbot_id-1.0.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for openbot-id 1.0.0
File Interpreter ABI Platform Actions
openbot_id-1.0.0-py3-none-any.whl Python 3 none any Details for openbot_id-1.0.0-py3-none-any.whl

Total release size: 11.3 kB

Release files / openbot_id-1.0.0.tar.gz

Download URL openbot_id-1.0.0.tar.gz
Size 5.8 kB
Tags Source
SHA-256 checksum
How to use checksums
85cc662be3df4db5d8489ed2b1e921a47e9b312084e17a67236a437160215a1c
BLAKE2b-256 checksum
How to use checksums
a5cc9459f2792ee365cd6d473c87097b7d0ab3d1798b1a9297e811f1c97f0ade
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.0.0-py3-none-any.whl

Download URL openbot_id-1.0.0-py3-none-any.whl
Size 5.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bc64a3c84b66ec9e9be5346535e3b3977106acfb16bb670fe0f0c36274932f0d
BLAKE2b-256 checksum
How to use checksums
d147f5d6f845eab54371646adce7d55c1a9fcac7402de453df9831879926b4ac
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.0.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.

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page