Links
in package
The routing table for one connector: which Discord channel is bridged to which of that platform's rooms.
Immutable and derived from whatever Store has persisted, so routing can be reasoned about — and tested — without a gateway, a socket, or a config file.
The two directions are deliberately asymmetric. A Discord channel bridges to
exactly one target, so Discord → platform is a lookup. But any number of
servers may follow the same target, so platform → Discord fans out to a
list; one message can land in many Discord channels across unrelated guilds.
Targets are held as strings throughout, whatever the platform calls them.
A Twitch login is a name, a Telegram supergroup id (-1001234567890) is
larger than a 32-bit int, and an @username is not a number at all, so
comparing them as strings is the only form correct for every platform.
Tags
Table of Contents
Properties
- $folded : array<string, string>
- $guilds : array<string|int, mixed>
- $toDiscord : array<string, array<int, string>>
- $toTarget : array<string, string>
Methods
- __construct() : mixed
- count() : int
-
diff()
: array{join: list
, part: list } - What to join and what to leave to get from this routing table to `$next`.
- discordFor() : array<int, string>
- Every Discord channel that should receive a message from a target — possibly across several guilds.
- forGuild() : array<string, string>
- One guild's links.
- guilds() : array<int, string>
- Every guild that has configured at least one bridge.
- isBridged() : bool
- Whether any Discord channel at all is bridged to this target.
- isEmpty() : bool
- targetFor() : string|null
- The target a Discord channel relays to, or `null` when unbridged.
- targets() : array<int, string>
- Every target the connector needs to be in, deduplicated: two guilds following the same room share one membership.
Properties
$folded
private
array<string, string>
$folded
= []
Case-folded target => the target as stored.
$guilds read-only
private
array<string|int, mixed>
$guilds
= []
$toDiscord
private
array<string, array<int, string>>
$toDiscord
= []
target => Discord channel ids.
$toTarget
private
array<string, string>
$toTarget
= []
Discord channel id => target.
Methods
__construct()
public
__construct([array<string, array<string, string>> $guilds = [] ]) : mixed
Parameters
- $guilds : array<string, array<string, string>> = []
-
guild id => [discord channel id => target]
count()
public
count() : int
Return values
intdiff()
What to join and what to leave to get from this routing table to `$next`.
public
diff(self $next) : array{join: list, part: list}
Returned as a diff rather than "just rejoin everything" so a config change in one guild does not blink every other guild's bridge offline.
Parameters
- $next : self
Return values
array{join: listdiscordFor()
Every Discord channel that should receive a message from a target — possibly across several guilds.
public
discordFor(int|string $target) : array<int, string>
Matched exactly, then case-insensitively. A network that echoes a room back in different case than it was configured in — IRC does — would otherwise deliver nothing, which reads exactly like a bridge that was never set up.
Parameters
- $target : int|string
Return values
array<int, string>forGuild()
One guild's links.
public
forGuild(int|string $guildId) : array<string, string>
Parameters
- $guildId : int|string
Return values
array<string, string> —discord channel id => target
guilds()
Every guild that has configured at least one bridge.
public
guilds() : array<int, string>
Return values
array<int, string>isBridged()
Whether any Discord channel at all is bridged to this target.
public
isBridged(int|string $target) : bool
Parameters
- $target : int|string
Return values
boolisEmpty()
public
isEmpty() : bool
Return values
booltargetFor()
The target a Discord channel relays to, or `null` when unbridged.
public
targetFor(int|string $discordChannelId) : string|null
Parameters
- $discordChannelId : int|string
Return values
string|nulltargets()
Every target the connector needs to be in, deduplicated: two guilds following the same room share one membership.
public
targets() : array<int, string>