Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Middleware functionality #35

Open
kritzware opened this issue Apr 9, 2018 · 0 comments
Open

Middleware functionality #35

kritzware opened this issue Apr 9, 2018 · 0 comments

Comments

@kritzware
Copy link
Owner

Issue for discussion about Bot middleware functionality and ideas.

Inspired by Express middleware functions.

Express implementation:

app.use(function (req, res, next) {
  console.log('Time:', Date.now())
  next()
})
Bot.use((chatter, send) => {
  // ... some sort of operation with the chatter object, or message string

  send() // Allows the message to be sent
})

In relation to this, the idea of custom Bot plugins would be cool e.g.

const TwitchBotCommands = require('twitch-bot-commands')

// The custom bot module
const commands = TwitchBotCommands("!", {
  "test": "command executed!",
  "tweet": async chatter => {
    const latestTweet = await someAsyncApiRequest(chatter.username)
    return `Latest tweet: ${latestTweet}`
  }
})

// Instantiate the module
Bot.module(commands)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant