ControlActions
in package
implements
ProvidesActions
uses
UsesTelegram
What the bridge can do *to* a Telegram chat, beyond relaying into it.
These were /tg when Telegram was the only network this bot knew. They are
/telegram chat … and /telegram mod … now, which is not decoration: send
and ban are words another connector will want, and a bare /tg alongside
/twitch invites the question of which one pin belongs to.
All of them act on the chat the invoking Discord channel is bridged to — Context::requireTarget() resolves that — which is what makes the unprivileged ones safe to leave open: they can only ever reach a chat someone with Manage Server already linked to that channel.
Tags
Table of Contents
Interfaces
- ProvidesActions
- A connector that brings commands of its own.
Constants
- POLL_ANSWER_LIMIT : mixed = 100
- POLL_MAX_OPTIONS : mixed = 10
- POLL_MIN_OPTIONS : mixed = 2
- Telegram's own bounds on a poll.
- POLL_QUESTION_LIMIT : mixed = 300
Methods
- actions() : array<int, Action>
- Every command this connector defines.
- splitPollOptions() : array<int, string>
- Splits `a, b, c` into answers, dropping the empties somebody's trailing comma leaves behind.
- attachmentUrl() : string
- The URL Discord resolved for an attachment option.
- ban() : PromiseInterface
- explain() : never
- Turns a Telegram failure into something worth reading.
- info() : PromiseInterface
- The panel: what the chat is, how many are in it, and the buttons.
- messageId() : int
- photo() : PromiseInterface
- Discord resolves the upload and gives us its CDN URL, which Telegram then fetches for itself — so the bytes never pass through this process.
- pin() : PromiseInterface
- poll() : PromiseInterface
- A real Telegram poll, not a relayed message with numbered lines.
- send() : PromiseInterface
- The relay in one direction, deliberately: whatever is typed here is said in the chat under the speaker's name, exactly as a relayed message would be.
- speaker() : string
- Who is speaking, and from where, for something posted on their behalf.
- telegram() : TelegramConnector
- titleOf() : string
- unban() : PromiseInterface
- unpin() : PromiseInterface
- With no id Telegram unpins the most recent pin, which is the common case and the only one somebody can act on without first reading an id out of a relayed message.
- userId() : int
Constants
POLL_ANSWER_LIMIT
private
mixed
POLL_ANSWER_LIMIT
= 100
POLL_MAX_OPTIONS
private
mixed
POLL_MAX_OPTIONS
= 10
POLL_MIN_OPTIONS
Telegram's own bounds on a poll.
private
mixed
POLL_MIN_OPTIONS
= 2
POLL_QUESTION_LIMIT
private
mixed
POLL_QUESTION_LIMIT
= 300
Methods
actions()
Every command this connector defines.
public
actions() : array<int, Action>
Return values
array<int, Action>splitPollOptions()
Splits `a, b, c` into answers, dropping the empties somebody's trailing comma leaves behind.
public
static splitPollOptions(string $raw) : array<int, string>
Parameters
- $raw : string
Return values
array<int, string>attachmentUrl()
The URL Discord resolved for an attachment option.
private
attachmentUrl(Context $context, string $id) : string
The option arrives as an attachment id; the file itself is in the interaction's resolved data, which is the only place it exists.
Parameters
- $context : Context
- $id : string
Return values
stringban()
private
ban(Context $context, Arguments $arguments) : PromiseInterface
Parameters
Return values
PromiseInterfaceexplain()
Turns a Telegram failure into something worth reading.
private
explain(Throwable $e) : never
Never re-uses the exception's own message unexamined: a Telegram error can quote the request URL, and a Telegram URL carries the bot token.
Parameters
- $e : Throwable
Return values
neverinfo()
The panel: what the chat is, how many are in it, and the buttons.
private
info(Context $context) : PromiseInterface
Parameters
- $context : Context
Return values
PromiseInterfacemessageId()
private
messageId(Arguments $arguments, bool $required) : int
Parameters
- $arguments : Arguments
- $required : bool
Return values
intphoto()
Discord resolves the upload and gives us its CDN URL, which Telegram then fetches for itself — so the bytes never pass through this process.
private
photo(Context $context, Arguments $arguments) : PromiseInterface
Parameters
Return values
PromiseInterfacepin()
private
pin(Context $context, Arguments $arguments) : PromiseInterface
Parameters
Return values
PromiseInterfacepoll()
A real Telegram poll, not a relayed message with numbered lines.
private
poll(Context $context, Arguments $arguments) : PromiseInterface
Worth reaching for: Telegram counts the votes, shows the results in the chat, and it is the one thing here with no Discord equivalent to relay.
Parameters
Return values
PromiseInterfacesend()
The relay in one direction, deliberately: whatever is typed here is said in the chat under the speaker's name, exactly as a relayed message would be.
private
send(Context $context, Arguments $arguments) : PromiseInterface
Parameters
Return values
PromiseInterfacespeaker()
Who is speaking, and from where, for something posted on their behalf.
private
static speaker(Context $context) : string
Typed in Telegram it needs no label. From Discord or Twitch it says so, as relayed chat does, so nobody is taken for a member of the chat.
Parameters
- $context : Context
Return values
stringtelegram()
private
telegram(Context $context) : TelegramConnector
Parameters
- $context : Context
Return values
TelegramConnectortitleOf()
private
titleOf(Context $context, string $chatId) : string
Parameters
- $context : Context
- $chatId : string
Return values
stringunban()
private
unban(Context $context, Arguments $arguments) : PromiseInterface
Parameters
Return values
PromiseInterfaceunpin()
With no id Telegram unpins the most recent pin, which is the common case and the only one somebody can act on without first reading an id out of a relayed message.
private
unpin(Context $context, Arguments $arguments) : PromiseInterface
Parameters
Return values
PromiseInterfaceuserId()
private
userId(Arguments $arguments) : int
Parameters
- $arguments : Arguments