DiscordPHP-BridgeBot Documentation

TwitchAdapter
in package

FinalYes

Runs the whole catalogue from Twitch chat.

The whole catalogue, deliberately: this is where !telegram send typed in a Twitch chat becomes a message in a Telegram group. One bot rather than two is only worth anything if the commands cross over, so every connector's actions are offered here, not just this one's.

Everything but the Twitch-specific parts is the core's ChatDispatcher, so access, cooldowns and cross-network targets behave exactly as they do in every other chat. What only this class knows is where Twitch keeps rank (badges, plus the configured owner) and the room's own id (the room-id tag, the broadcaster's user id, so no lookup is needed).

TwitchPHP's own CommandClient is not used. It matches a single word and enforces its own cooldowns, so it would see !twitch and nothing after it — and a second cooldown clock that disagrees with the one Discord uses.

Tags
author

Valithor Obsidion valithor@valgorithms.com

Table of Contents

Properties

$connector  : TwitchConnector
$dispatcher  : ChatDispatcher

Methods

__construct()  : mixed
fromSharedChat()  : bool
Whether a message was typed in *another* channel's chat and is being shown here through Twitch's Shared Chat.
handle()  : bool
Runs a line of chat if it is a command, reporting whether it was.
invocation()  : ChatInvocation
Who typed a message and where, as the dispatcher needs it.
safeLine()  : string
Makes a line safe to hand to `Irc::say()`.

Properties

Methods

fromSharedChat()

Whether a message was typed in *another* channel's chat and is being shown here through Twitch's Shared Chat.

public static fromSharedChat(ChatMessage $message) : bool

During a shared session every participating channel receives every participant's messages, tagged with the room they came from. A command typed over there is not addressed to this channel, and its sender's rank was earned over there — so it is not run here at all. (Like any command line, it is not relayed either.)

Parameters
$message : ChatMessage
Return values
bool

handle()

Runs a line of chat if it is a command, reporting whether it was.

public handle(ChatMessage $message) : bool

Replies go through the connector, and so through the account's one send budget: command replies and relayed chat speak as the same account, and two senders that each stay under Twitch's limit still breach it together.

Parameters
$message : ChatMessage
Return values
bool

safeLine()

Makes a line safe to hand to `Irc::say()`.

public static safeLine(string $text) : string

Kept as a named entry point because it is the project's single most security-relevant function and is tested directly; the implementation is TwitchText::safeLine().

Parameters
$text : string
Return values
string
On this page

Search results