Skip to content

A very basic and simplified chat bot for Mixer

Notifications You must be signed in to change notification settings

tje/mixer-chatbot

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Summary

An attempt to simplify chat bot creation on Mixer.

Usage

Create a new ChatBot instance using your own authentication token, then connect to a channel by calling the joinChannel method.

const chatToken = 'your-secret-chat-token'
const channelId = 'MixerChannelName'

const bot = new ChatBot(chatToken)
bot.joinChannel(channelId)
.then(socket => {
  socket.on('chat:join', ({ username }) => console.log(`Joined: ${username}`))
  socket.on('chat:leave', ({ username }) => console.log(`Left: ${username}`))
  socket.on('chat:message', message => {
    console.log(`${message.author}: ${message.text}`)

    if (message.text.startsWith('!ping')) {
      message.reply('Pong!')
    }
  })
})
.catch(err => {
  console.error(err)
})

See the examples directory for more, uh... examples.

Events

Many of these events have been aggregated from Mixer's own beam-client-node and Constellation. Each event relays the original event packet from Mixer, with the exception of chat:message, which is unique in that it provides a ChatMessage object instead for convenience.

Event Description
chat:message A new chat message or a whisper is received.
chat:clear Chat has been cleared.
chat:purge A user has been banned or purged in chat.
chat:delete A message has been deleted.
user:join User joined chat.
user:leave User left chat.
user:timeout The bot has been timed out.
user:update A user has been updated.
poll:start A new poll has been started.
poll:end A poll has ended.
channel:followed Channel gained a new follower.
channel:hosted Channel is being hosted.
channel:unhosted Channel is no longer being hosted.
channel:updated Channel has been updated.
channel:online Stream has gone online.
channel:offline Stream has stopped.

ChatMessage

The ChatMessage object has the following properties:

  • author: The username of the sender.
  • text: The chat message.
  • type: Either "public" or "private" in the case of a whisper.
  • _raw: The original payload from Mixer.

You can call the reply(response[, asWhisper]) method to react immediately to a chat message. The asWhisper parameter is optional and mimics the original message's visibility (respond to whispers with a whisper), passing true or false will force it to be a public or private response respectively.

About

A very basic and simplified chat bot for Mixer

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published