API reference

These pages are generated from the docstrings in the code. Everything public is importable from pgpcbot:

from pgpcbot import Bot, Button, InlineKeyboard, filters as f

Names that start with _ (modules and attributes) are internal and can change in any version. The same documentation is available without a browser: help(pgpcbot.Bot) in Python, or python -m pydoc pgpcbot.Bot in a terminal.

Where to find what

Page

Contents

Bot and SyncBot

Bot and SyncBot: running a bot, sending, encryption helpers, hooks, failed updates

AsyncClient and Client

AsyncClient and Client: one method per operation of the Bot API; RetryPolicy, RateLimiter, Secret

Models

the objects the API returns and handlers receive

Keyboards

Button, InlineKeyboard, KeyboardBuilder

Routers and filters

Router, SkipHandler and the filters module

Keys and encryption

BotKey, PublicKey, Verification

Storage

MemoryStorage, SQLiteStorage, writing your own

Webhook

WebhookApp, generate_secret()

Exceptions

every exception, with the server’s error codes

Conventions

  • Async and sync. Every async class has a sync twin with the same methods: on the sync one, call them without await (Async and sync).

  • Keyword arguments. Options are keyword-only; only the main values (the chat, the text, the IDs) are positional.

  • Chats. Bot methods take a chat ID or any chat object (a Chat, a ChatRef, message.chat).

  • Validation. Input is checked against the server’s rules before anything is sent: a ValidationError means nothing left the process.

  • Errors. Each method lists the errors specific to it. Any call that reaches the server can also raise the errors listed in Errors every method can raise.

  • Models are read-only and keep the server’s JSON in raw.