'Using a Telegram Bot, can a user trigger another user session of the bot?
I have a big problem. I'm looking like a day to find a solution.
I created a Telegram Bot with the user sessions.
I need a user from his session to be able to update another user's session.
I have already tried to use a sendMessage from the session of the first user which goes to send a message to the session of the second user. But I can't handle this message because, as I've seen, the bot.on() method only handle the message from the user, not from himself.
Any idea?
UPDATE 1: Ok I think I have to give you more information.
There are 2 users. The 2nd user has a button. With the click of this button I want to run some logic on the session of the first user. At the moment with the click of the button I'm sending a msg in the session of the first user, but I can't trigger any logic.
Here the method inside the command triggered by clicking the button of the 2nd user:
bot.command('leave', async (ctx: MyContext)=>{
try{
await ServiceHelper.updateSession(ctx.session.chatId!, "");
await ctx.api.sendMessage(ctx.session.chatId!, "The user left the conversation 🧐", {reply_markup:{resize_keyboard: true, one_time_keyboard: true, keyboard: MenuChat.chatLeftMenu.build()} });
ctx.session={
...ctx.session,
chatId: "",
step: "startMenu"
}
await MsgHandlerStart.managerStart(ctx);
}
catch(error){
await ctx.answerCallbackQuery({text: ctx.i18n.t("answer-callback.wrong-command")});
}
});
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
