DefaultKeyBuilder
in package
implements
KeyBuilder
Simple colon-joined key builder with an `fsm` prefix.
Mirrors aiogram.fsm.storage.base.DefaultKeyBuilder
(aiogram/fsm/storage/base.py:42-99). Segment order matches upstream
exactly:
<prefix>[:<botId>][:<businessConnectionId>]:<chatId>[:<threadId>]:<userId>[:<destiny>][:<part>]
Optional segments are controlled by constructor flags:
$withBotId— includebotId$withBusinessConnectionId— includebusinessConnectionId(only when non-null on the key)$withDestiny— always include thedestinysegment.
When $withDestiny is false (the default), the default destiny segment is
omitted for compact keys, but non-default destiny values are still included.
This keeps ordinary FSM keys stable while allowing scene-history and custom
destiny slots to live in isolated backend keys.
Table of Contents
Interfaces
- KeyBuilder
- Contract for assembling a string key from an FSM {@see StorageKey} and an optional sub-record discriminator.
Properties
- $prefix : string
- $separator : string
- $withBotId : bool
- $withBusinessConnectionId : bool
- $withDestiny : bool
Methods
- __construct() : mixed
- build() : string
- Assemble and return the storage key string.
Properties
$prefix read-only
private
string
$prefix
= 'fsm'
$separator read-only
private
string
$separator
= ':'
$withBotId read-only
private
bool
$withBotId
= false
$withBusinessConnectionId read-only
private
bool
$withBusinessConnectionId
= false
$withDestiny read-only
private
bool
$withDestiny
= false
Methods
__construct()
public
__construct([string $prefix = 'fsm' ][, string $separator = ':' ][, bool $withBotId = false ][, bool $withBusinessConnectionId = false ][, bool $withDestiny = false ]) : mixed
Parameters
- $prefix : string = 'fsm'
-
String prefix prepended to every generated key.
- $separator : string = ':'
-
Token placed between each key segment.
- $withBotId : bool = false
-
When
true, the bot ID segment is included. - $withBusinessConnectionId : bool = false
-
When
true, the business-connection-ID segment is included (only if the key'sbusinessConnectionIdis non-null). - $withDestiny : bool = false
-
When
true, the destiny segment is always included. Whenfalse, only non-default destiny values are included.
build()
Assemble and return the storage key string.
public
build(StorageKey $key[, null|StoragePart $part = null ]) : string
Parameters
- $key : StorageKey
-
Contextual key.
- $part : null|StoragePart = null
-
Optional sub-record discriminator; appended as the final segment when non-null.
Return values
string —Assembled key string.