kameloso.plugins.twitch

This is a Twitch channel bot. It supports song requests, counting how many times an emote has been used, reporting how long a viewer has been a follower, how much time they have spent watching the stream, and some miscellanea.

For local use it can also emit some terminal bells on certain events, to draw attention.

If the promote* settings are toggled, some viewers will be automatically given privileges based on their channel "status"; one of broadcaster, moderator and VIPs. Viewers that don't fall into any of those categories are not given any special permissions unless awarded manually. Nothing promotes into the whitelist class as it's meant to be assigned to manually.

Mind that the majority of the other plugins still work on Twitch, so you also have the Counter plugin for death counters, the Quotes plugin for streamer quotes, the Timer plugin for timed announcements, the Oneliners plugin for oneliner commands, etc.

Modules

api
module kameloso.plugins.twitch.api

Functions for accessing the Twitch API. For internal use.

common
module kameloso.plugins.twitch.common

Common Twitch bits and bobs.

emotes
module kameloso.plugins.twitch.emotes

Functions related to importing and embedding custom emotes.

providers
module kameloso.plugins.twitch.providers
stub
module kameloso.plugins.twitch.stub

Twitch plugin stub, to provide lines to the configuration file even when the bot isn't compiled in.

Members

Aliases

SongRequestMode
alias SongRequestMode = SRM

Alias to SRM.

Classes

TwitchPlugin
class TwitchPlugin

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

Enums

SRM
enum SRM

Song requests may be either disabled, or either in YouTube or Spotify mode.

Functions

appendToStreamHistory
void appendToStreamHistory(TwitchPlugin plugin, TwitchPlugin.Room.Stream stream)

Appends a Stream to the history file.

complainAboutMissingTokens
void complainAboutMissingTokens(Exception base)

Helper function to complain about missing Twitch authorisation tokens..

initResources
void initResources(TwitchPlugin plugin)

Reads and writes resource files to disk, ensure that they're there and properly formatted.

initRoom
void initRoom(TwitchPlugin plugin, string channelName)

Registers a new TwitchPlugin.Room as we join a channel, so there's always a state struct available.

initialise
void initialise(TwitchPlugin plugin)

Start any key generation terminal wizard(s) before connecting to the server.

loadResources
void loadResources(TwitchPlugin plugin)

Loads all resources from disk.

onAnyMessage
void onAnyMessage(TwitchPlugin plugin, IRCEvent event)

Bells on any message, if the TwitchSettings.bellOnMessage setting is set. Also counts emotes for ecount and records active viewers.

onBusMessage
void onBusMessage(TwitchPlugin plugin, string header, Sendable content)

Receives a passed Boxed instance with the "twitch" header, and issues whispers based on its Message payload.

onCommandCommercial
void onCommandCommercial(TwitchPlugin plugin, IRCEvent event)

Starts a commercial in the current channel.

onCommandEcount
void onCommandEcount(TwitchPlugin plugin, IRCEvent event)

!ecount; reporting how many times a Twitch emote has been seen.

onCommandEndPoll
void onCommandEndPoll(TwitchPlugin plugin, IRCEvent event)

Ends a Twitch poll.

onCommandFollowAge
void onCommandFollowAge(TwitchPlugin plugin, IRCEvent event)

Implements "Follow Age", or the ability to query the server how long you (or a specified user) have been a follower of the current channel.

onCommandNuke
void onCommandNuke(TwitchPlugin plugin, IRCEvent event)

Deletes recent messages containing a supplied word or phrase.

onCommandRepeat
void onCommandRepeat(TwitchPlugin plugin, IRCEvent event)

Repeats a given message n number of times.

onCommandSetGame
void onCommandSetGame(TwitchPlugin plugin, IRCEvent event)

Changes the game of the current channel.

onCommandSetTitle
void onCommandSetTitle(TwitchPlugin plugin, IRCEvent event)

Changes the title of the current channel.

onCommandShoutout
void onCommandShoutout(TwitchPlugin plugin, IRCEvent event)

Emits a shoutout to another streamer.

onCommandSongRequest
void onCommandSongRequest(TwitchPlugin plugin, IRCEvent event)

Implements !songrequest, allowing viewers to request songs (actually YouTube videos or Spotify tracks) to be added to the streamer's playlist.

onCommandStartPoll
void onCommandStartPoll(TwitchPlugin plugin, IRCEvent event)

Starts a Twitch poll.

onCommandSubs
void onCommandSubs(TwitchPlugin plugin, IRCEvent event)

Reports the number of subscribers of the current channel.

onCommandUptime
void onCommandUptime(TwitchPlugin plugin, IRCEvent event)

Reports how long the streamer has been streaming.

onCommandVanish
void onCommandVanish(TwitchPlugin plugin, IRCEvent event)

Hides a user's messages (making them "disappear") by briefly timing them out.

onCommandWatchtime
void onCommandWatchtime(TwitchPlugin plugin, IRCEvent event)

Implements !watchtime; the ability to query the bot for how long the user (or a specified user) has been watching any of the channel's streams.

onEndOfMOTD
void onEndOfMOTD(TwitchPlugin plugin)

Sets up various things after we have successfully logged onto the server.

onGlobalUserstate
void onGlobalUserstate(TwitchPlugin plugin)

Fetches global custom BetterTV, FrankerFaceZ and 7tv emotes.

onImportant
void onImportant(TwitchPlugin plugin, IRCEvent event)

Bells on any important event, like subscriptions, cheers and raids, if the TwitchSettings.bellOnImportant setting is set.

onMyInfo
void onMyInfo(TwitchPlugin plugin)

Sets up a fiber to periodically cache followers.

onNonHomeRoomState
void onNonHomeRoomState(TwitchPlugin plugin, IRCEvent event)

Fetches custom BetterTV, FrankerFaceZ and 7tv emotes for a any non-home channel iff version TwitchCustomEmotesEverywhere.

onRoomState
void onRoomState(TwitchPlugin plugin, IRCEvent event)

Records the room ID of a home channel, and queries the Twitch servers for the display name of its broadcaster.

onSelfjoin
void onSelfjoin(TwitchPlugin plugin, IRCEvent event)

Registers a new TwitchPlugin.Room as we join a channel, so there's always a state struct available.

onSelfpart
void onSelfpart(TwitchPlugin plugin, IRCEvent event)

Removes a channel's corresponding TwitchPlugin.Room when we leave it.

onUserstate
void onUserstate(TwitchPlugin plugin, IRCEvent event)

Warns if we're not a moderator when we join a home channel.

postprocess
void postprocess(TwitchPlugin plugin, IRCEvent event)

Hijacks a reference to a IRCEvent and modifies the sender and target class based on their badges (and the current settings).

promoteUserFromBadges
void promoteUserFromBadges(IRCUser.Class class_, string badges, bool promoteModerators, bool promoteVIPs)

Infers a user's class based on their badge(s).

reload
void reload(TwitchPlugin plugin)

Reloads the plugin, loading resources from disk and re-importing custom emotes.

reportStreamTime
void reportStreamTime(TwitchPlugin plugin, TwitchPlugin.Room room)

Reports how long a broadcast has currently been ongoing, up until now lasted, or previously lasted.

saveResourceToDisk
void saveResourceToDisk(RehashingAA!(long[string])[string] aa, string filename)

Saves the passed resource to disk, but in JSON format.

saveSecretsToDisk
void saveSecretsToDisk(Credentials[string] aa, string filename)

Saves Twitch secrets to disk, in JSON format.

setup
void setup(TwitchPlugin plugin)

Initialises the response bucket, else its internal Mutex will be null and cause a segfault when trying to lock it.

startRoomMonitors
void startRoomMonitors(TwitchPlugin plugin, string channelName)

Starts room monitors as Fibers for a given channel.

startSaver
void startSaver(TwitchPlugin plugin)

Starts a saver routine.

startValidator
void startValidator(TwitchPlugin plugin)

Starts a validator routine.

teardown
void teardown(TwitchPlugin plugin)

De-initialises the plugin. Shuts down any persistent worker threads.

Structs

Credentials
struct Credentials

Credentials needed to access APIs like that of Google and Spotify.

Follower
struct Follower

Embodiment of the notion of someone following someone else on Twitch.

TwitchSettings
struct TwitchSettings

All Twitch plugin runtime settings.

See Also

Meta