I use the following code to perform a broadcast. However, if I input broadcast message with "/", for example "please type /help for help.", the broadcast message will not be prompted.
I found that when the input contains "/", the message will be treated as command. At this point, I don't know what is the cause and don't know how can I fix that.
'use strict';
const { bot, flow } = require('../bot');
const db = require('../db');
const util = require('../util');
bot.onText(/^\/broadcast$/, msg => {
const chatId = msg.from.id;
// flow guard
if(!flow.hasInQueue(chatId)) {
const isAdminUser = db.isAdminUser(chatId);
if(!isAdminUser) {
return;
}
bot.sendMessage(chatId, 'Please input broadcast message');
// after 180 second, the operation will be forcibly cleared
const timer = setTimeout(flow.clear.bind(flow), 180000, chatId);
flow.register(
chatId,
async data => {
const msg = data.executeCallData;
util.notifyRoles(chatId, ['admin', 'poweruser'], '🔔BROADCAST MESSAGE🔔\n🔔PLEASE DO NOT REPLY🔔\n' + msg.text, true, false);
bot.sendMessage(chatId, 'done');
clearTimeout(timer);
},
);
} else {
bot.sendMessage(chatId, 'Unable to execute this command. First complete the previous operation or type /clear.');
}
});