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
$cachedId
private
int|null
$cachedId
= null
$cachedMe
private
User|null
$cachedMe
= null
$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
Closurecurrent()
public
static current() : Bot|null
Return values
Bot|nulldownload()
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|nulldownloadFile()
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|nullgetId()
public
getId() : int
Return values
intme()
public
me() : User
Return values
UsersetCurrent()
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|nullmakeBotLocal()
private
static makeBotLocal(callable(): Array $init) : FiberLocal<string|int, Bot|null>
Parameters
- $init : callable(): Array