telebot icon indicating copy to clipboard operation
telebot copied to clipboard

Multi-layered events(sub-events)

Open ajganiev opened this issue 8 years ago • 2 comments

Is it possible to implement multi-layered event system? What i mean is to separate each event-layer by "." character and be able to use upper layer as middleware. For example:

bot.on('some_event', (msg) => {
      //do something
      next();
})

bot.on('some_event.sub_event', (msg) => {
     //do something again
});

For now I have found this solution:

bot.on('some_event', (msg) => {
     //do something
     bot.event(`some_event.${msg.sub_event_name}`, msg);
})

ajganiev avatar Aug 02 '17 17:08 ajganiev

Yep, you can make chains. Are you satisfied with this solution?

mullwar avatar Aug 03 '17 11:08 mullwar

Yeah, it is working fine for me, but are you planning to add this feature in future?

ajganiev avatar Aug 03 '17 15:08 ajganiev