Middleware functionality
Opened this issue · 0 comments
kritzware commented
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)