phpbotgram

BotShortcuts

Table of Contents

Properties

$cachedId  : int|null
$cachedMe  : User|null
$currentBotLocals  : array<class-string, FiberLocal<string|int, Bot|null>>
Per-class FiberLocal slots, keyed by `static::class`. A trait-level `private static ?FiberLocal` would otherwise collapse across the using class hierarchy (Bot + MockedBot would share one slot).

Methods

context()  : Closure
`($bot->context())(function (Bot $bot) { … })` — the body closure receives `$this` as its single argument so callers can avoid `use ($bot)` clutter.
current()  : Bot|null
download()  : string|null
Mirrors aiogram's `bot.download(file: str | Downloadable, ...)`. A bare `string` is treated as a `file_id` and resolved via `getFile` before downloading; a `Downloadable` (Document/Photo/Voice/etc) is unwrapped via its `fileId()` method.
downloadFile()  : string|null
getId()  : int
me()  : User
setCurrent()  : void
botLocal()  : FiberLocal<string|int, Bot|null>
consumeStream()  : string|null
makeBotLocal()  : FiberLocal<string|int, Bot|null>

Properties

$currentBotLocals

Per-class FiberLocal slots, keyed by `static::class`. A trait-level `private static ?FiberLocal` would otherwise collapse across the using class hierarchy (Bot + MockedBot would share one slot).

private static array<class-string, FiberLocal<string|int, Bot|null>> $currentBotLocals = []

Methods

context()

`($bot->context())(function (Bot $bot) { … })` — the body closure receives `$this` as its single argument so callers can avoid `use ($bot)` clutter.

public context([bool $autoClose = true ]) : Closure

Mirrors upstream's async with bot.context() as bot: binding.

Parameters
$autoClose : bool = true
Return values
Closure

download()

Mirrors aiogram's `bot.download(file: str | Downloadable, ...)`. A bare `string` is treated as a `file_id` and resolved via `getFile` before downloading; a `Downloadable` (Document/Photo/Voice/etc) is unwrapped via its `fileId()` method.

public download(Downloadable|string $object[, mixed $destination = null ][, int $timeout = 30 ][, int $chunkSize = 65536 ]) : string|null
Parameters
$object : Downloadable|string
$destination : mixed = null
$timeout : int = 30
$chunkSize : int = 65536
Return values
string|null

downloadFile()

public downloadFile(File|string $fileOrPath[, mixed $destination = null ][, int $timeout = 30 ][, int $chunkSize = 65536 ]) : string|null
Parameters
$fileOrPath : File|string
$destination : mixed = null
$timeout : int = 30
$chunkSize : int = 65536
Return values
string|null

setCurrent()

public static setCurrent(Bot|null $bot) : void
Parameters
$bot : Bot|null

botLocal()

private static botLocal() : FiberLocal<string|int, Bot|null>
Return values
FiberLocal<string|int, Bot|null>

consumeStream()

private consumeStream(ReadableStream $stream, mixed $destination) : string|null
Parameters
$stream : ReadableStream
$destination : mixed
Return values
string|null

makeBotLocal()

private static makeBotLocal(callable(): Array $init) : FiberLocal<string|int, Bot|null>
Parameters
$init : callable(): Array
Return values
FiberLocal<string|int, Bot|null>
On this page

Search results