TwitchPlugin

The Twitch plugin is an example Twitch streamer bot. It contains some basic tools for streamers, and the audience thereof.

version(TwitchSupport && WithTwitchPlugin)
final
class TwitchPlugin : IRCPlugin {}

Members

Enums

QueryConstants
enum QueryConstants

Constants used when scheduling API queries.

Functions

isEnabled
bool isEnabled()

Override IRCPlugin.isEnabled

(effectively overriding IRCPluginImpl.isEnabled) and inject a server check, so this plugin only works on Twitch, in addition to doing nothing when TwitchSettings.enabled is false.

Manifest constants

clientID
enum clientID;

The Twitch application ID for kameloso.

delegateRetries
enum delegateRetries;

How many times to retry a Twitch server query.

Mixins

__anonymous
mixin IRCPluginImpl
Undocumented in source.

Structs

Room
struct Room

Contained state of a channel, so that there can be several alongside each other.

Variables

approximateQueryTime
long approximateQueryTime;

How long a Twitch HTTP query usually takes.

authorizationBearer
string authorizationBearer;

Authorisation token for the "Authorization: Bearer <token>".

bell
string bell;

Effective bell after kameloso.terminal.isTerminal checks.

bucket
QueryResponse[int] bucket;

Associative array of responses from async HTTP queries.

customEmotesByChannel
bool[dstring][string] customEmotesByChannel;

Custom channel-specific BetterTTV, FrankerFaceZ and 7tv emotes, as fetched via API calls.

customGlobalEmotes
bool[dstring] customGlobalEmotes;

Custom global BetterTTV, FrankerFaceZ and 7tv emotes, as fetched via API calls.

ecount
RehashingAA!(string, long)[string] ecount;

Emote counters associative array; counter longs keyed by emote ID string keyed by channel.

ecountDirty
bool ecountDirty;

Whether or not ecount has been modified and there's a point in saving it to disk.

ecountFile
string ecountFile;

File to save emote counters to.

persistentWorkerTid
Tid persistentWorkerTid;

The thread ID of the persistent worker thread.

rooms
Room[string] rooms;

Array of active bot channels' state.

secretsByChannel
Credentials[string] secretsByChannel;

API keys and tokens, keyed by channel.

secretsFile
string secretsFile;

File to save API keys and tokens to.

streamHistoryFile
string streamHistoryFile;

File to save stream history to.

twitchSettings
TwitchSettings twitchSettings;

All Twitch plugin settings.

userID
string userID;

The bot's numeric account/ID.

viewerTimesByChannel
RehashingAA!(string, long)[string] viewerTimesByChannel;

Associative array of viewer times; seconds keyed by nickname keyed by channel.

viewerTimesDirty
bool viewerTimesDirty;

Whether or not viewerTimesByChannel has been modified and there's a point in saving it to disk.

viewersFile
string viewersFile;

File to save viewer times to.

Mixed In Members

From mixin IRCPluginImpl

pattern
enum pattern;
Undocumented in source.
message
enum message;
Undocumented in source.
Introspection
struct Introspection

Namespace for the alias sequences of all event handler functions in this module, as well as the one of all IRCEventHandler annotations in the module.

isEnabled
bool isEnabled()

Introspects the current plugin, looking for a Settings-annotated struct member that has a bool annotated with Enabler, which denotes it as the bool that toggles a plugin on and off.

onEvent
void onEvent(IRCEvent event)

Forwards the supplied IRCEvent to IRCPluginImpl.onEventImpl.

this
this(IRCPluginState state)

Basic constructor for a plugin.

postprocess
void postprocess(IRCEvent event)

Lets a plugin modify an IRCEvent while it's begin constructed, before it's finalised and passed on to be handled.

initResources
void initResources()

Writes plugin resources to disk, creating them if they don't exist.

deserialiseConfigFrom
void deserialiseConfigFrom(string configFile, string[][string] missingEntries, string[][string] invalidEntries)

Loads configuration for this plugin from disk.

setSettingByName
bool setSettingByName(string setting, string value)

Change a plugin's Settings-annotated settings struct member by their string name.

printSettings
void printSettings()

Prints the plugin's Settings-annotated settings struct.

serialiseConfigInto
bool serialiseConfigInto(Appender!(char[]) sink)

Gathers the configuration text the plugin wants to contribute to the configuration file.

name
string name()

Returns the name of the plugin. (Technically it's the name of the module.)

channelSpecificCommands
IRCPlugin.CommandMetadata[string] channelSpecificCommands(string channelName)

Compile a list of our a plugin's oneliner commands.

commands
IRCPlugin.CommandMetadata[string] commands()

Forwards to IRCPluginImpl.commandsImpl.

onBusMessage
void onBusMessage(string header, Sendable content)

Proxies a bus message to the plugin, to let it handle it (or not).

Inherited Members

From IRCPlugin

CommandMetadata
struct CommandMetadata

Metadata about a IRCEventHandler.Command- and/or IRCEventHandler.Regex-annotated event handler.

state
IRCPluginState state;

An IRCPluginState instance containing variables and arrays that represent the current state of the plugin. Should generally be passed by reference.

postprocess
void postprocess(IRCEvent event)

Allows a plugin to modify an event post-parsing.

onEvent
void onEvent(IRCEvent event)

Called to let the plugin react to a new event, parsed from the server.

initResources
void initResources()

Called when the plugin is requested to initialise its disk resources.

deserialiseConfigFrom
void deserialiseConfigFrom(string configFile, string[][string] missingEntries, string[][string] invalidEntries)

Reads serialised configuration text into the plugin's settings struct.

serialiseConfigInto
bool serialiseConfigInto(Appender!(char[]) sink)

Called to let the plugin contribute settings when writing the configuration file.

setSettingByName
bool setSettingByName(string setting, string value)

Called when we want to change a setting by its string name.

setup
void setup()

Called at program start but before connection has been established.

start
void start()

Called when connection has been established.

printSettings
void printSettings()

Called when we want a plugin to print its Settings-annotated struct of settings.

teardown
void teardown()

Called during shutdown of a connection; a plugin's would-be destructor.

name
string name()

Returns the name of the plugin.

commands
CommandMetadata[string] commands()

Returns an array of the descriptions of the commands a plugin offers.

channelSpecificCommands
CommandMetadata[string] channelSpecificCommands(string )

Returns an array of the descriptions of the channel-specific commands a plugin offers.

reload
void reload()

Reloads the plugin, where such is applicable.

onBusMessage
void onBusMessage(string header, Sendable content)

Called when a bus message arrives from another plugin.

isEnabled
bool isEnabled()

Returns whether or not the plugin is enabled in its settings.

Meta