告诉我为什么时事通讯对我的机器人用户不起作用?
所有用户的id都记录在bd中
const { Telegraf, Markup, Scenes, session } = require('telegraf');
const bot = new Telegraf(process.env.BOT_TOKEN);
const db = require("./database/db-pool");
我想做的是从数据库中提取每个用户并使用 /sendAd 命令向他发送消息
bot.command('sendAd', async (ctx) => {
try {
const conn = await db.getConnection();
const [rows] = await conn.query('SELECT * FROM users');
conn.release();
for (const row of rows) {
console.log(`Sending a message to a user chatId: ${row.chatId}`);
await ctx.telegram.sendMessage(row.chatId, 'Your advertising message is here');
}
ctx.reply('Advertising sent to all users');
} catch (error) {
console.error(error);
ctx.reply('There was an error sending the ad.');
}
});
请帮助我
只是命令之前有一个块正在吞噬所有短信..
bot.on('text', async (ctx) => {
if (ctx.session.complainStep === 'waiting_for_complaint')
..
像这样