Hello thanks to you, I developed Stake Telegram Bot. Thank you very much. However Telegram Bot send message 2 times to the group. How can I resolve this bug. ( I use railway app )
require("dotenv").config();
const express = require("express");
const TelegramBot = require("node-telegram-bot-api");
const app = express();
const port = process.env.PORT || 3000;
const TELEGRAM_BOT_TOKEN = process.env.TELEGRAM_BOT_TOKEN;
const bot = new TelegramBot(TELEGRAM_BOT_TOKEN, { polling: true });
app.use(express.json());
app.post("/webhook", async (req, res) => {
const webhook = req.body;
for (const erc20Transfer of webhook.erc20Transfers) {
const fromAddress = `${erc20Transfer.from.slice(
0,
8
)}...${erc20Transfer.from.slice(38)}`;
const tokenItem = `${erc20Transfer.valueWithDecimals} ${erc20Transfer.tokenName}`;
let subtitle = `NEW STAKE ALERT 🚨🚨`;
let locktime = `🔒 Lock Time:`;
let locktimevalue = `30 Days | Early Unstake Fee 25%`;
let stake = `Staked Amount:`;
let fromAdd = `Staker Address:`;
let powered = `🤖🏛 Powered by @AIBNKCoin`;
const chatId = -1001987231854;
var replyText = subtitle.bold() + "\n" + "\n" +"💰" + " " + fromAdd.bold() + "\n" + fromAddress + "\n" + "\n" + "💵" + " " + stake.bold() + "\n" + tokenItem + "\n" + "\n" + locktime.bold() + "\n" + locktimevalue + "\n" + "\n" + powered;
var option = {
"parse_mode": "HTML",
};
bot.sendMessage(chatId, replyText, option);
}
return res.status(200).json();
});
app.listen(port, () => {
console.log(`Listening for AIBANK STAKE Transfers`);
});```