Open potb opened 1 year ago
I think we need some sort of middlewares solution for this. First thought is https://github.com/fastify/avvio
For further context, we had a discussion with @neolectron and are considering adopting an approach similar in terms of its implementation. The intended usage of the modules is illustrated below:
const workflow = [
voiceOnDemand(), // Configurable standalone module for voice-on-demand.
patternReplacement() // Configurable standalone module for pattern replacement.
.after(autoThread((context) => context.newMessage)) // Takes input from previous module; also configurable standalone.
.after(summarizer((context) => context.autoThreadedChannelId)), // Takes input from previous module; also configurable standalone.
summarizer(), // Configurable standalone module for summarizing.
autoThread(), // Configurable standalone module for auto-threading.
];
The way we handle events right now makes performing multiple actions at the same time difficult.
For example, when we post a twitter link in an autothread channel, the link won't be replaced by a vxtwitter one.
Maybe we can look into a sequential way of handling our events, using an array of handlers for example.