MessageMap
in package
Remembers which message on one network became which message on the other, so an edit can follow it across.
Bounded and in memory on purpose. An edit almost always follows within minutes of the message, so the useful window is short; persisting it would mean a growing file of ids that stop existing, and keeping it unbounded would mean a bridge that slowly eats the host's memory for a feature nobody uses on a week-old message. When an entry has been evicted — or the process restarted — the bridge falls back to relaying the edit as a new message, which is worse than editing in place but better than dropping it.
Tags
Table of Contents
Properties
Methods
- __construct() : mixed
- count() : int
- How many messages are currently remembered.
- forget() : void
- lookup() : T|null
- What a message became, or `null` when it is no longer remembered.
- remember() : void
- Records what a message became.
- telegramKey() : string
- The key for one Telegram message.
Properties
$capacity read-only
private
int
$capacity
= 500
$entries
private
array<string, T>
$entries
= []
Insertion-ordered; the oldest key is evicted first.
Methods
__construct()
public
__construct([int $capacity = 500 ]) : mixed
Parameters
- $capacity : int = 500
-
How many messages to remember.
count()
How many messages are currently remembered.
public
count() : int
Return values
intforget()
public
forget(string $key) : void
Parameters
- $key : string
lookup()
What a message became, or `null` when it is no longer remembered.
public
lookup(string $key) : T|null
Parameters
- $key : string
Return values
T|nullremember()
Records what a message became.
public
remember(string $key, T $value) : void
Parameters
- $key : string
- $value : T
telegramKey()
The key for one Telegram message.
public
static telegramKey(int|string $chatId, int|string $messageId) : string
Parameters
- $chatId : int|string
- $messageId : int|string