kritzware/twitch-bot

New Features

Opened this issue ยท 4 comments

Hello twitch-bot users!

This issue is for discussion around ideas/requests for new features, feel free to leave a comment if you have any thoughts ๐Ÿ˜„

Some thoughts:

  • Defining commands in an object (potentially some sort of config file, or JSON), with helper methods for more advanced commands (e.g. fetching from an api)
const commands = {
  'twitter': 'Check out my twitter at https://twitter.com/twitch! PogChamp',
  '123': chatter => `Message: ${chatter.message}`
  'points': async (chatter) => {
     // Access to the chatter object
     const points = await fetchPointsFromDatabase()
     return `You have ${points} points ${chatter.username}!`
  }
}

Bot.define(commands)
  • More examples, with an example folder e.g. how to setup commands, how to use the bot for chat stats/monitoring etc.

  • Built in rate limiter to avoid bot spam, something along these lines

const Bot = new TwitchBot({
  username: 'bot',
  oauth: 'oauth:oauth-key-123',
  channels: ['twitch'],
  limit: 10 // Sets limit of 10 IRC messages per 30 seconds, or some other timespan 
})

I think rate limiter is definitely a priority for anyone who wants to use this library in a production environment.

Getting the core features done right on this bot might be more important than implementing extra features. It could be hard to gain adoption if people realize that they have to reimplement the core of the bot to make it more resilient.

When receiving a message event, maybe we should have the chance to check if the Bot is currently being rate limited so that they can decide whether to continue further in their business logic or just to ignore the message?

Questions:

  • Commands should be customizable for each channel that the Bot is connected to right?

  • Do we also need to rate limit joins and parts per channel so that one channel can't be spammed with JOINs and affect other channels who are also trying to be joined? The current limit is 50 joins per 15 seconds I think

  • Currently, if the message rate limit is reached in one channel, does that stop the Bot from sending messages in other channels as well?

Regarding message limits: https://dev.twitch.tv/docs/irc#irc-command-and-message-limits

Regarding join limits:
https://discuss.dev.twitch.tv/t/the-final-answer-on-join-limits/8505

Such a limitation is definitely useful. For other features, maybe we should keep the "core" of the bot clean so we just implement all raw Twitch-Chat related message parsing and handling and then delegate additional features to a plugin-system?

  • adding event for user join and part
  • adding event for cheer