diff --git a/index.js b/index.js index 1bded71..afa716d 100644 --- a/index.js +++ b/index.js @@ -27,6 +27,11 @@ function deleteChatId(from) { delete chat_ids[from]; } +function updateChatId(from, chat_id) { + chat_ids[from] = chat_id; + logger.verbose('Chat id ' + chat_id + ' ' + from); +} + function sendMessage(destination, message) { var chat_id = chat_ids[destination]; @@ -59,7 +64,7 @@ bot.on('text', function (msg) { return; } - chat_ids[from] = msg.chat.id; + updateChatId(from, msg.chat.id); var greeting_prefix = "Pesan anda telah diterima:"; if (config.greeting_prefix) {