Skip to main content

Openbot API 1.2.0

Python library to check Telegram user roles and levels against your Openbot ID server.

Install

pip install openbot_api

Until the new package is published to PyPI, install the local wheel included in the release archive.

Usage

import os
import telebot
import openbot_api

bot = telebot.TeleBot(os.environ["TELEGRAM_BOT_TOKEN"])
openbot = openbot_api.OpenbotAPI(api_key=os.environ["OPENBOT_API_KEY"], bot=bot)

@bot.message_handler(commands=["start"])
@openbot.check_level("tester", level=2)
@openbot.check_level("developer", level=2)
def start(message):
    bot.reply_to(message, "✅ Доступ разрешён!")

bot.infinity_polling()

Two stacked check_level decorators grant access if either status and its required level match.

Other methods: get_user(id), get_status(id), get_level(id), has_level(id, role, level), check_access(id), and require_access().

Checking several statuses

if not openbot.check_access(
    message.from_user.id,
    ("developer", "tester", "admin", "owner"),
    level=1,
):
    bot.reply_to(message, "⛔ Недостаточно прав!")
    return

This checks the user's exact status and minimum level, with OR across the requested statuses. It does not implicitly grant access to owner unless owner is included. The former openbot.check_access(user_id) is still supported and delegates to the server's general policy.

Legacy bot compatibility (new in 1.2.0)

get_id(user_id) (returns tuple or None), get_user_level(user_id), check_dev_tester_level(user_id, required_level=1), is_dev_or_owner(user_id), is_globally_banned(user_id), get_developers_count(), get_active_bots(user_id) and the ROLE/LEVEL mappings.

Write methods register_bot_activity(user_id, bot_name), create_id(user_id, name, emoji=None), update_bio(user_id, bio), set_status(user_id, new_status, level=1), toggle_dev_mode(user_id) require server administrator credentials (passed as admin_key= or OPENBOT_ADMIN_API_KEY). They are not available to ordinary public API key holders. Do not distribute the administrator key to other developers or publicly distributed bots.

The associated server endpoints are not available until the administrator installs server-extension/api_extensions.py and includes its routers as documented in server-extension/README.md.

The API key is a secret. Do not commit it to Git, place it in bot source, or share it publicly. The client is intentionally read-only: new keys may only be issued by an authorized administrator on the server, not through an unauthenticated public endpoint.

API keys on Linux server

See server-key-tools/README.md in the release archive. Back up your existing key database before replacing any existing files. api_keys.py and manage_keys.py are server-side tools and must not be published as part of the Python package.

Metadata

Release files for openbot-api 1.2.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-api 1.2.0
File Size Uploaded Provenance Actions
openbot_api-1.2.0.tar.gz 7.6 kB Without provenance Details for openbot_api-1.2.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for openbot-api 1.2.0
File Interpreter ABI Platform Actions
openbot_api-1.2.0-py3-none-any.whl Python 3 none any Details for openbot_api-1.2.0-py3-none-any.whl

Total release size: 14.8 kB

Release files / openbot_api-1.2.0.tar.gz

Download URL openbot_api-1.2.0.tar.gz
Size 7.6 kB
Tags Source
SHA-256 checksum
How to use checksums
0bb7a2adc9218f888dc06c3314f1350725962303c7ef019d2c33280ba9d45fb7
BLAKE2b-256 checksum
How to use checksums
a68d84211e556751c9b8238bd3c9c3f82642f4f5d11e695cbb10413c3adc7d68
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Release files / openbot_api-1.2.0-py3-none-any.whl

Download URL openbot_api-1.2.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b9e5e271e12c88a4537dc0f497aaf7927d8928b6c56ecea6d43458a3fe840c0f
BLAKE2b-256 checksum
How to use checksums
f2664e49f08616aecb541587496bf998336bd862aa395aa761bbbe2a26431381
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.7

Security for openbot-api 1.2.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.

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