diff --git a/examples/edit-caption.js b/examples/edit-caption.js
index 3951569..6dd85c8 100644
--- a/examples/edit-caption.js
+++ b/examples/edit-caption.js
@@ -1,7 +1,7 @@
const TeleBot = require('../');
const bot = new TeleBot('TELEGRAM_BOT_TOKEN');
-var lastMessage;
+var lastMessage = {};
var photoUrl = 'https://telegram.org/img/tl_card_destruct.gif';
bot.on('/start', msg => {
@@ -11,7 +11,7 @@ bot.on('/start', msg => {
msg.from.id, photoUrl, {caption: 'This is a default caption.'}
).then(re => {
// Get message id and chat
- lastMessage = [msg.from.id, re.result.message_id];
+ lastMessage[msg.from.id] = [msg.from.id, re.result.message_id];
bot.sendMessage(msg.from.id, 'Now set a new caption using /edit
');
});
@@ -19,11 +19,11 @@ bot.on('/start', msg => {
bot.on('/edit', msg => {
- if (!lastMessage) {
+ if (!lastMessage[msg.from.id]) {
return bot.sendMessage(msg.from.id, 'Type /start and then /edit ');
}
- let [chatId, messageId] = lastMessage;
+ let [chatId, messageId] = lastMessage[msg.from.id];
let caption = msg.text.replace('/edit ', '');
if (caption == '/edit') caption = 'No caption.';
diff --git a/examples/edit-markup.js b/examples/edit-markup.js
index 716c51f..a937955 100644
--- a/examples/edit-markup.js
+++ b/examples/edit-markup.js
@@ -1,7 +1,7 @@
const TeleBot = require('../');
const bot = new TeleBot('TELEGRAM_BOT_TOKEN');
-var lastMessage;
+var lastMessage = {};
bot.on('/start', msg => {
@@ -11,7 +11,7 @@ bot.on('/start', msg => {
msg.from.id, 'This is a editMessageReplyMarkup example. So, apples or oranges?', {markup}
).then(re => {
// Start updating message
- lastMessage = [msg.from.id, re.result.message_id];
+ lastMessage[msg.from.id] = [msg.from.id, re.result.message_id];
});
});
@@ -22,10 +22,10 @@ bot.on('callbackQuery', msg => {
// Send confirm
bot.answerCallbackQuery(msg.id);
- if (!lastMessage) return bot.sendMessage(msg.from.id, 'Type /start');
+ if (!lastMessage[msg.from.id]) return bot.sendMessage(msg.from.id, 'Type /start');
const data = msg.data;
- const [chatId, messageId] = lastMessage;
+ const [chatId, messageId] = lastMessage[msg.from.id];
const replyMarkup = updateKeyboard(data);
// Edit message markup