电报机器人状态栏

时间:2018-07-09 21:34:14

标签: node.js telegram telegram-bot

CHR$(149)

到目前为止,在用户按下“ Dancy file”按钮之后,我已经有了这段代码来使用Bot in Telegram发送消息和曲目。当然,要花些时间才能将曲目上载到用户。我有一段代码,将Bot的状态更改为“发送音频”。 这是这个:bot.on('message', (msg) => { var dancy_file = "dancy file"; if (msg.text.toString().toLowerCase().indexOf(dancy_file) === 0) { bot.sendChatAction(msg.chat.id, 'upload_audio'); name = (dancy_files[rand_dancy_files()]); // root var path = __dirname + "/dancy_files/" + name; // track size sent_file_size = getFilesizeInMB(path); // all tracks size total_size += sent_file_size; console.log("MB's sent: ", total_size); // send track with new keyboard bot.sendAudio(msg.chat.id, "/root/dancy_files/" + name); bot.sendMessage(msg.chat.id, "Your dancy song is uploading, please be patient: ", { "reply_markup": { "keyboard": [["More dancy tracks"], ["Back to choose file style"]], "resize_keyboard": true } }); // console logs var date = new Date(); // console.log(msg.from.first_name, msg.from.last_name + " wants dancy at", date.getHours(), ":", date.getMinutes()); var name = msg.from.first_name + msg.from.last_name + "wants dancy at"; var str = name + date.getHours() + ":" + date.getMinutes() + '\n'; console.log(str); fs.appendFile("/root/log.txt", str, function (err) { if (err) { return console.log(err); } console.log("The file was saved!"); }); } });

我该怎么做,仅在上传曲目时才保持此状态。目前,它只执行一次,并在按下按钮后一直显示。 关键思想是跟踪Bot上传跟踪所花费的时间。

0 个答案:

没有答案