Closed jlanza closed 4 years ago
It seems that is working:
menuTemplate.interact('menu', 'set', {
do: async (ctx) => {
referralQuestion.replyWithMarkdown(ctx,
'Please enter the new item for ' + ctx.match![1] + '.[ ](http://t.me/#menupath'
+ ctx.match![0]
+ ')');
return false;
}
});
And then on the stateless question you just create a Regex and retrieve the value you desire:
ctx.message.reply_to_message.entities![0].url!.match(myRegex);
instead of ctx.match![0]
you can use the second argument of do:
menuTemplate.interact('Text', 'unique', {
do: async (context, path) => {
console.log('interaction', path, context.update)
return false;
}
});
As the menu template is independent of what the context is (its generic) the MenuMiddleware does all the context magic.
Generic MenuTemplates have no clue what the context is about, but path
is always a string containing the path.
With an update of the inline-menu library and the stateless-question library there is now a fairly simple way of doing this.
I updated the README entry Didnt this menu had a question function? accordingly.
I'll just close this due to inactivity. If you have any questions feel free to ask ahead!
Describe your goal I want to use the stateless question to set the values after clicking on a menu button. The point is this button is generated after clicking on a choose menu template. Anyway, the issue here is that when you use the stateless question doesn't have the menu path.
I was thinking on including an empty text link with the menu path in the question text so I can then return to the same menu position.
What do you think about that? If it works I will post and maybe can be included in the examples.
Edit: I take the opportunity to inform that it seems to be a kind of bug in stateless question. Every time I enter a chat the stateless question is displayed.