This is a simple example plugin describing how to use twitchr-plugin-api while writing plugins for twitchr.
This plugin is based on the recommended plugin structure.
Its PluginEventListener
defines a hook function for the PRIVMSG
event:
const hooks: api.PluginEventListener = {
onMessage: onMessage,
};
This hook function is implemented as follows:
function onMessage(irc: api.IrcContext<api.IrcMessage>): void {
const args: api.IrcMessage = <api.IrcMessage>irc.getArgs();
const name: string = irc.getName();
irc.send(`hello, ${args.user}!`);
if (args.user !== name) {
irc.timeout(args.user, 5);
debugPlugin(`${args.user} was timed out`);
}
}
If a message event is triggered, this plugin responds with a short greeting and performs a timeout lasting 5 seconds if the message sender was not the bot itself.
The plugin depends on debug
which is used to log debug statements whenever a timeout happens.
Additional helper methods which are currently supported are listed in the plugin API.
For any yet unsupported chat command you can use the send()
method.
The full list of all possible commands to be executed can be found here.
This project is licensed under the terms of the MIT license.