This repository was archived by the owner on Oct 21, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 28
This repository was archived by the owner on Oct 21, 2023. It is now read-only.
reply and replyWithMarkdown doesn't work in prod #23
Copy link
Copy link
Open
Description
I have quite an unusual bot behaviour. I have a simple bot which was scaffolded with create-bot
/micro-bot
. It listens for a few commands and does some API calls. It was working fine, and yesterday, but since this morning it stopped responding on the prod servers (now
).
yarn dev
work perfectly, everything as expected. When pushed to prod; bot doesn't respond to any reply
or replyWithMarkdown
. Yet I can see all console.log statements, logs in the now dashboard, database being updated, but still, no bot replies.
I'm genuinely confused, did someone came across this issue?
Some code examples:
now.json
{
"version": 1
}
package.json
(i'm using secrets to store bot token, and it worked very well yesterday)
"scripts": {
"dev": "supervisor -x micro-bot index.js",
"start": "micro-bot",
"lint": "eslint .",
"now-start": "micro-bot -d ${NOW_URL}",
"now-deploy": "now -e BOT_TOKEN=@token_bot --public"
}
index.js
// Register "/start" command
bot.start(ctx => {
const currentUsername = ctx.update.message.from.username;
const chatId = ctx.update.message.chat.id;
const formattedChatId = chatId.toString();
let activeUsernames;
if (currentUsername && formattedChatId) {
// Query to target the correct document in the chats collection
const chatInstance = db.collection("chats").doc(formattedChatId);
// Read document data
chatInstance
.get()
.then(doc => {
if (!doc.exists) {
// No such document with this formattedChatId
// so we create a new chat record in db
// and pass a currentUsername
services.createNewChatRecord(chatInstance, currentUsername);
} else {
activeUsernames = doc.data().usernames;
if (!activeUsernames.includes(currentUsername)) {
// currentUsername is not included in the active username list
// so we update the current record in db
// and pass already activeUsernames list and currentUsername.
services.updateUsernamesRecord(
chatInstance,
activeUsernames,
currentUsername
);
}
}
})
.then(() => {
ctx.replyWithMarkdown(messages.INIT_START_COMMAND);
})
.catch(err => {
ctx.replyWithMarkdown(messages.ERROR_MESSAGE);
console.log("Error getting data", err);
});
}
});
junedl-nimblechapps
Metadata
Metadata
Assignees
Labels
No labels