Security News
Combatting Alert Fatigue by Prioritizing Malicious Intent
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
node-twitchbot
Advanced tools
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.
Version 2.0.0^ (Recommended):
$ npm install node-twitchbot
Version 1 (Deprecated):
$ npm install node-twitchbot@1.2.2
const TwitchBot = require('node-twitchbot')
const Bot = new TwitchBot({
username : 'GLADOS',
oauth : 'oauth:secret-oauth-pass'
channel : 'Aperture'
})
/* Listen for all messages in channel */
Bot.listen((err, chatter) => {
if(err) {
console.log(err)
} else {
console.log(chatter)
}
})
/* Listen for an exact messages match */
Bot.listenFor('KKona', (err, chatter) => {
console.log(chatter)
})
/* Send a message in the channel */
Bot.msg('this is the message text PogChamp')
/* Listen for raw IRC events */
Bot.raw((err, event) => {
console.log(event)
})
const Bot = require('node-twitchbot')
Bot.run({
username: 'bot_username',
oauth: 'oauth:twitch_oauth_key',
channel: 'channel'
})
/* Exact message match */
Bot.listenFor('Kappa', (err, chatter) => {
if(err) {
console.log(err)
} else {
console.log(chatter)
}
})
/* Return all user message in channel */
Bot.listenFor('*', (err, chatter) {
// Returns all viewer messages in channel
})
/* String is included in message */
Bot.listen('PogChamp', (err, chatter) => {
console.log(chatter)
})
/* Sub/resub event in chat */
Bot.resub((err, chatter, sub) => {
console.log(sub)
})
/* Say messages in chat */
Bot.msg('Hello chat!')
/* Private message user */
Bot.whisper('kritzware', 'This is a private message Kappa')
/* Setting commands instead of checking via string match */
const commands = {
help : 'For help using this bot, contact kritzware',
twitter : 'Follow this channel at https://twitter.com/test123',
/* You can also use functions to generate a command response */
random : (chatter) => {
return Math.floor((Math.random() * -1) + 1)
},
/* Command functions can make use of the chatter object of the user who executed the command */
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)
}
})
{
user: 'KRITZWARE',
msg: 'Hello chat! Keepo',
channel: 'kritzware',
user_id: '44667418'
level: 'mod',
sub: '0',
turbo: '0'
}
Bot.listenFor('!command', (err, chatter) => {
Bot.msg('This is the command response')
})
FAQs
Easily create chat bots for Twitch.tv
The npm package node-twitchbot receives a total of 4 weekly downloads. As such, node-twitchbot popularity was classified as not popular.
We found that node-twitchbot demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
In 2023, data breaches surged 78% from zero-day and supply chain attacks, but developers are still buried under alerts that are unable to prevent these threats.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.