mixer-bot
v0.1.2
Published
Simplified chat bot for the mixer live streaming platform
Downloads
13
Maintainers
Readme
mixer-bot
Richard Wen
[email protected]
Simplified chat bot for the mixer live streaming platform
Note: This is based on a Mixer chat bot tutorial on the developer's page
Install
npm install -g mixer-bot
For the latest developer version, see Developer Notes.
Usage
The mixerbot
package can be used as a command line tool or programatically in Node.js.
In the Command Line
Create a .env
file in the current directory if it does not exist:
- Replace
<token>
with your access token - A file
.env
will be created (do not share this file)
mixer-bot env <token>
To run a mixer-bot:
<name>
is the name of the mixer-bot npm package or .js file
mixer-bot run <name>
If you want to create your own mixer-bot:
- Create a bot template file
mixer-bot template
- Edit this file to change bot behaviour
- Run the both with
mixer-bot run
mixer-bot template ./template.js
mixer-bot run template.js
In Node.js
An example usage of mixer-bot in node
:
const mixerbot = require('mixer-bot');
// Create a .env file in the same location and set
// MIXER_ACCESS_TOKEN=***
// MIXER_CHANNEL_ID=***
// Setup options
var options = {};
options.on = {};
options.greeting = 'Hello!';
// Setup channel ID
// If left unset, this will be the id to your channel
// Get your channel id here: https://mixer.com/api/v1/channels/<username>?fields=id
// options.channel_id = '<CHANNEL_ID>';
// Welcome a user when they join
options.on.UserJoin = data => {
socket = data.socket;
return response => {
socket.call('msg',[
`Hi ${response.username}! I'm pingbot! Write !ping and I will pong back!`,
]);
}
};
// Assign bot to pong user if they message !ping
options.on.ChatMessage = data => {
socket = data.socket;
return response => {
if (response.message.message[0].data.toLowerCase().startsWith('!ping')) {
socket.call('msg', [`@${response.user_name} PONG!`]);
console.log(`Ponged ${response.user_name}`);
}
}
};
// Handle errors
options.on.error = data => {
return error => {
console.error('Socket error');
console.error(error);
}
};
// Run mixer bot
mixerbot(options);
See Documentation for more details.
Contributions
- Reports for issues and suggestions can be made using the issue submission interface.
- Code contributions are submitted via pull requests
See CONTRIBUTING.md for more details.