mixer-bot

0.1.2 • Public • Published

mixer-bot

Richard Wen
rrwen.dev@gmail.com

Simplified chat bot for the mixer live streaming platform

npm version Build Status npm GitHub license Donate Twitter

Note: This is based on a Mixer chat bot tutorial on the developer's page

Install

  1. Install Node.js
  2. Install mixer-bot via npm
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:

  1. Create a bot template file mixer-bot template
  2. Edit this file to change bot behaviour
  3. 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

  1. Reports for issues and suggestions can be made using the issue submission interface.
  2. Code contributions are submitted via pull requests

See CONTRIBUTING.md for more details.

See Also

Package Sidebar

Install

npm i mixer-bot

Weekly Downloads

2

Version

0.1.2

License

MIT

Unpacked Size

1.59 MB

Total Files

47

Last publish

Collaborators

  • rrwen