Skip to content

Chatbot framework that listens and sends messages to multiple live-streaming platforms simultaneously

Notifications You must be signed in to change notification settings

HackerShackOfficial/multi-stream-chatbot

Repository files navigation

multi-stream-chatbot

Chatbot framework that listens and sends messages to multiple live-streaming platforms simultaneously

NPM

Watch our demo video to learn more

Documentation

Quick Start

Create a node project:

npm init

Post the following content in index.js:

const { StreamBot } = require("multi-stream-chatbot")
const {TwitchStream} = require("multi-stream-chatbot/streams")
const TwitchAuth = require("multi-stream-chatbot/auth/twitch")
const {AbstractSimpleChatAction, MessageParser} = require("multi-stream-chatbot/actions")

// Create an action
class DiceRollAction extends AbstractSimpleChatAction {
    matchesCommand(message, ctx) {
        return new MessageParser().parseCommand(message) === "!dice"
    }

    async makeMessage(message, ctx) {
        const num = this.rollDice()
        return `You rolled a ${num}`
    }

    rollDice() {
        const sides = 6
        return Math.floor(Math.random() * sides) + 1
    }
}

const actions = [new DiceRollAction()]

// Configure twitch auth
const twitchAuth = new TwitchAuth({
    oauthToken: process.env.TWITCH_BOT_KEY,
    botUsername: process.env.TWITCH_BOT_USERNAME,
    channel:  process.env.TWITCH_CHANNEL
})

// Create a bot
const bot = new StreamBot({
    streams: [new TwitchStream(twitchAuth)],
    actions
})

// Start the bot
bot.start()

Create environment variables for your Twitch stream authentication:

TWITCH_BOT_KEY,
TWITCH_BOT_USERNAME,
TWITCH_CHANNEL

Run the program:

node index.js

Streams

Supports:

  • Youtube
  • Twitch
  • Dummy (Interval)

Actions

SimpleChatAction

Handles one command. See DiceAction for more details.

var {
    AbstractSimpleChatAction,
} = require("multi-stream-chatbot/actions")

StrategyBasedChatAction

Handles multiple commands that share state. See PollActions for more details.

var {
    AbstractStrategyBasedChatAction,
    AbstractMessageStrategy,
} = require("multi-stream-chatbot/actions")

Test Locally

npm test
npm pretty

Example

See the Hacker Shack livestream chatbot repo to see usage examples.

Donations

Thanks for the support!

  • Zachary Nawrocki: Love your videos. I've been working on a chat bot for my personal home assistant project, and these ideas have given me some inspiration. Thanks.

About

Chatbot framework that listens and sends messages to multiple live-streaming platforms simultaneously

Resources

Stars

Watchers

Forks

Packages

No packages published