codinglab-io / discord-bot

Discord bot for Codinglab's server.
https://discord.com/invite/codinglab-174169014568878080
MIT License
19 stars 14 forks source link

Actions triggered by events don't work together #38

Open potb opened 1 year ago

potb commented 1 year ago

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.

neolectron commented 1 year ago

I think we need some sort of middlewares solution for this. First thought is https://github.com/fastify/avvio

potb commented 1 year ago

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.
];