jt3k / chat-linker

the bridge between jabber and telegram over chat-bots
MIT License
46 stars 9 forks source link

Add plugin support #66

Open jt3k opened 6 years ago

jt3k commented 6 years ago

It would be great if the chat-linker could support the plug-ins.

This would make it easier to add functionality, for example anti-spam or anti-obscene-swearing.

At the first stage, I would like to see a synchronous or asynchronous middleware. For example, as it is done in axios interceptors or babel-plugin

plugin example:

module.exports = ({
 interceptors: [
  {
   from: 'telegram', // or from: '*'
   to: 'xmpp',
   interceptor({ network, name, message, room }) {
    // message processing here
    return { network, name, message, room }
   }
  }
 ]
})