node-twitchbot
Note: This package is not to be used for Twitch botting (inflating live viewer counts) and should only be used for chatbots. Attempting to 'bot' a Twitch channel can lead to your account being permanently banned.
Installation
$ npm install node-twitchbot
V2 DOCS (Currently Unreleased)
Example
const TwitchBot = require('node-twitchbot')
const Bot = new TwitchBot({
username : 'GLADOS',
oauth : 'oauth:secret-oauth-pass'
channel : 'Aperture'
})
Bot.listen((err, chatter) => {
if(err) {
console.log(err)
} else {
console.log(chatter)
}
})
Bot.listenFor('KKona', (err, chatter) => {
console.log(chatter)
})
Bot.msg('this is the message text PogChamp')
Bot.raw((err, event) => {
console.log(event)
})
V1 DOCS
Example
const Bot = require('node-twitchbot')
Bot.run({
username: 'bot_username',
oauth: 'oauth:twitch_oauth_key',
channel: 'channel'
})
Bot.listenFor('Kappa', (err, chatter) => {
if(err) {
console.log(err)
} else {
console.log(chatter)
}
})
Bot.listenFor('*', (err, chatter) {
})
Bot.listen('PogChamp', (err, chatter) => {
console.log(chatter)
})
Bot.resub((err, chatter, sub) => {
console.log(sub)
})
Bot.msg('Hello chat!')
Bot.whisper('kritzware', 'This is a private message Kappa')
const commands = {
help : 'For help using this bot, contact kritzware',
twitter : 'Follow this channel at https://twitter.com/test123',
random : (chatter) => {
return Math.floor((Math.random() * -1) + 1)
},
goodnight : (chatter) => {
return 'Goodnight ' + chatter.user + '! FeelsGoodMan'
}
}
Bot.commands('!', commands, (err, chatter, command) => {
if(err) {
console.log(err)
} else {
console.log(command)
console.log(chatter)
}
})
Output for example '!goodnight' command above
Chatter : user object
{
user: 'KRITZWARE',
msg: 'Hello chat! Keepo',
channel: 'kritzware',
user_id: '44667418'
level: 'mod',
sub: '0',
turbo: '0'
}
Example of a command
Bot.listenFor('!command', (err, chatter) => {
Bot.msg('This is the command response')
})