BridgeActions
in package
implements
ProvidesActions
The six commands every connector gets: `link`, `here`, `unlink`, `list`, `status` and `reset`.
Defined once, under whichever connector they are constructed for, so
/twitch link and /telegram link do the same thing in the same words and
cannot drift apart — and a network nobody has written a package for yet
arrives with its configuration commands already done.
The permission gate is the security model
All six are limited to whoever the server belongs to, and that is the whole
security model of the project: whoever can run link decides which Discord
channel gets copied into a public chat somewhere else. Point it at a private
channel and that channel is on stream.
Replies are ephemeral — configuration is nobody else's business, and it keeps the channel clean.
Tags
Table of Contents
Interfaces
- ProvidesActions
- A connector that brings commands of its own.
Constants
- CONFIRM_RESET : mixed = 'reset'
- The component action the `reset` confirmation button carries.
Properties
Methods
- __construct() : mixed
- actions() : array<int, Action>
- Every command this connector defines.
- confirmed() : PromiseInterface
- The `reset` button, pressed.
- channel() : string
- Which Discord channel an argument names, defaulting to the one the command was typed in.
- here() : PromiseInterface
- link() : PromiseInterface
- list() : string
- permissionNote() : string
- A warning when the bot cannot post where it has just been told to.
- requireChannelInGuild() : void
- Refuses a channel from another server.
- reset() : string|PanelBuilder
- Asks first. Clearing every bridge in a server is irreversible, and it is exactly the kind of thing somebody fires while meaning `list` — so this answers with a confirmation panel, and the clearing happens in {@see self::confirmed()} when its button is pressed.
- status() : string
- target() : string
- Whatever was typed, as the connector addresses rooms.
- unlink() : string
Constants
CONFIRM_RESET
The component action the `reset` confirmation button carries.
public
mixed
CONFIRM_RESET
= 'reset'
Properties
$connector read-only
private
Connector
$connector
Methods
__construct()
public
__construct(Connector $connector) : mixed
Parameters
- $connector : Connector
actions()
Every command this connector defines.
public
actions() : array<int, Action>
Return values
array<int, Action>confirmed()
The `reset` button, pressed.
public
static confirmed(Bot $bot, Interaction $interaction, string $connectorName) : PromiseInterface
The rung is checked again here rather than trusted from when the panel was drawn. A prefix command's reply is visible to the whole channel, so the person pressing the button need not be the person who asked.
Parameters
- $bot : Bot
- $interaction : Interaction
- $connectorName : string
Return values
PromiseInterfacechannel()
Which Discord channel an argument names, defaulting to the one the command was typed in.
private
channel(Context $context, Arguments $arguments, int $position) : string
Accepts <#id> because that is what a Discord channel picker renders to
and what someone types by hand; both surfaces therefore agree.
Parameters
Return values
stringhere()
private
here(Context $context, Arguments $arguments) : PromiseInterface
Parameters
Return values
PromiseInterfacelink()
private
link(Context $context, Arguments $arguments) : PromiseInterface
Parameters
Return values
PromiseInterfacelist()
private
list(Context $context) : string
Parameters
- $context : Context
Return values
stringpermissionNote()
A warning when the bot cannot post where it has just been told to.
private
permissionNote(Context $context, string $channelId) : string
A bridge that is configured correctly but cannot post looks exactly like one that is misconfigured, and the only evidence is an absence — so it is said up front rather than discovered when the first message vanishes.
Parameters
- $context : Context
- $channelId : string
Return values
stringrequireChannelInGuild()
Refuses a channel from another server.
private
requireChannelInGuild(Context $context, string $channelId, string $guildId) : void
The permission gate checks that the invoker administers this server. A channel mention is just an id, and the bot sits in many servers, so without this an admin of one could name a channel in another — where they may have no rights at all — and have it relayed into a public chat.
Parameters
- $context : Context
- $channelId : string
- $guildId : string
Tags
reset()
Asks first. Clearing every bridge in a server is irreversible, and it is exactly the kind of thing somebody fires while meaning `list` — so this answers with a confirmation panel, and the clearing happens in {@see self::confirmed()} when its button is pressed.
private
reset(Context $context) : string|PanelBuilder
Parameters
- $context : Context
Return values
string|PanelBuilderstatus()
private
status(Context $context) : string
Parameters
- $context : Context
Return values
stringtarget()
Whatever was typed, as the connector addresses rooms.
private
target(string|null $raw) : string
Parameters
- $raw : string|null
Return values
stringunlink()
private
unlink(Context $context, Arguments $arguments) : string