Soo... I'm working on a Telegram Bot for Node.JS, after a user joined, my bot will welcome them:
function Welcome(e)
{
console.log("Neuer Member");
console.log(e); //Das ist der, der joint
let markup = Extra.markup(
Markup.inlineKeyboard([
Markup.callbackButton('I read the rules and accept them!', 'AcceptRules'),
Markup.urlButton('Read the rules here', 'https://t.me/MyBot')
])
);
bot.telegram.restrictChatMember(e.chat.id, e.from.id, {can_send_messages: false, can_send_media_messages: false, can_send_other_messages: false});
e.reply(`Welcome to the chat @${e.message.from.username}, please make sure to read the rules https://t.me/MyBot\n\nYou will be able to chat in here once you read them :3\n\n If you have trouble you can use this button right here to accept AFTER you read them ;3`, markup, Extra.inReplyTo(e.update.message.message_id))
}
The message when the User joins the chat
After the user joined the chat, the can click on the left button attached to the message, to the Callback.Button, which triggers this function:
bot.action('AcceptRules', e => {
//if(e.update.callback_query.from.username == )
let markup = Extra.markup(
Markup.inlineKeyboard([
Markup.urlButton('Read the rules here', 'https://t.me/VenWaifuBot')
])
);
//Das ist der, der akzeptiert
allow(e);
e.editMessageText(`✅Thank you ${e.update.callback_query.from.first_name} for reading the rules! I hope you have fun here ;3\n\nYou can always read the rules here, they will be updates from time to time`, markup);
console.warn(e);
});
So my question is... how can I be sure that ONLY the person who joined --> User triggers Welcome(e) funciton when joining --> Username is in local e variable
e.update.message.from.username from the user who joined
e.update.callback_query.from.username is the user who clicked on the button
But both are local variables...
How can I pass that variable from the Welcome Message to the bot.action Event?
I thoght about making a temporary global memory which stores the username, but what if another user joins in the time and interferes... making an array also seems a bit off... anyone has a solution?
Sincerly Ven