All classes live under the Pam\Telegram namespace. This page documents version 0.1.1.
? Transport $transport = null,
SessionStore | false | null $sessions = null, // null: MemorySessionStore, false: no sessions
? Closure $sessionKey = null, // fn (Context): ?string, default chat id
?string $username = null, // default: fetched once with getMe
?string $webhookSecret = null,
Method
Description
use(callable $middleware)
Adds middleware fn (Context $ctx, Closure $next).
on(string|array $filter, callable $handler)
Handles updates matching a filter query .
command(string|array $names, callable $handler)
Handles /commands; $ctx->match is the argument text.
hears(string $pattern, callable $handler)
Handles exact text or a regex.
callbackQuery(string $pattern, callable $handler)
Handles button data, exact or regex.
scene(string $name, callable ...$steps)
Registers a scene.
cancelScenesOn(array $commands)
Commands that abort any scene (default ['cancel']).
catch(callable $handler)
Error handler fn (Throwable $error, Context $ctx).
handle(array $update)
Processes one update.
handleWebhook(string $body, ?string $secretToken = null)
Processes a webhook request; returns 200, 400, or 401.
setWebhook(string $url, array $extra = [])
Calls setWebhook with the configured secret.
run(int $timeout = 30, array $allowedUpdates = [], bool $dropPendingUpdates = false, int $limit = 100, ?Closure $shouldStop = null)
Long polling.
stop()
Stops run() after the current update.
username()
The bot’s username.
Public property: api (Api). Constant: SCENE_KEY ('__scene').
Member
Description
update, api, bot
Read-only: the raw update, the API client, the bot.
session
The per-chat session array.
match
Command arguments, matched text, or regex groups.
scene
The running Scene inside a scene step, otherwise null.
updateId(), type(), payload()
Update ID, update type, and the update’s payload.
message(), callbackQuery(), inlineQuery()
The relevant parts of the update.
from(), chat(), chatId(), userId()
The user and chat behind the update.
text(), callbackData(), command()
Text or caption, button data, parsed command.
reply(), replyWithPhoto(), replyWithDocument(), typing()
Send to the current chat.
answer(), edit(), editMarkup(), delete()
Act on the callback query or its message.
enter(string $scene, array $data = []), leave()
Enter or leave a scene.
Properties name, step, and data. Methods next(), back(), to(int $step), and leave().
? Transport $transport = null,
string $baseUrl = 'https://api.telegram.org' ,
float $maxRetryAfter = 60.0 ,
? RateLimiter $rateLimiter = null,
Method
Description
call(string $method, array $params = [], ?float $timeout = null)
Calls any Bot API method and returns its result.
download(string $fileId, int $maxBytes = 20 * 1024 * 1024)
Downloads a file’s bytes.
__call()
$api->sendMessage(...) with named arguments or one array.
Class
Description
Keyboard\InlineKeyboard
Inline buttons: text(), url(), webApp(), copyText(), switchInline(), pay(), button(), row().
Keyboard\Keyboard
Reply keyboards: text(), requestContact(), requestLocation(), webApp(), button(), row(), resized(), oneTime(), persistent(), placeholder(), remove(), forceReply().
InputFile
Uploads: fromPath(string $path, ?string $filename = null), fromContents(string $contents, string $filename).
Format
html(string) and markdownV2(string) escaping.
RateLimiter
new RateLimiter(float $perSecond = 30.0, float $privateChatInterval = 1.0, float $groupInterval = 3.0, int $maxTrackedChats = 10_000).
Session\SessionStore
Interface: read(), write(), delete().
Session\MemorySessionStore
new MemorySessionStore(int $maxEntries = 10_000, float $ttl = 86_400.0).
Session\CacheSessionStore
new CacheSessionStore(CacheInterface $cache, string $prefix = 'pam_telegram.session.', ?int $ttl = 86_400).
Transport\Transport
Interface with one request() method.
Transport\AutoTransport, CurlTransport, PamTransport, StreamTransport
Built-in transports.
Exception
Description
Exception\TelegramException
Telegram refused a request. method, errorCode, description, parameters, retryAfter(), migrateToChatId().
Exception\TransportException
The Bot API could not be reached, or the response was invalid.
Invalid configuration, such as a malformed token, webhook secret, or polling limits, throws InvalidArgumentException when the object is created or the method is called.