[英]Send message using telegram bot with Node.js
I'm doing a service to warn me of possible errors that can occur on my server , my doubt is , after I send a message as I finalize the execution or the way it is presenting the image below normal? 我正在做一项服务,以警告我服务器上可能发生的错误,我的疑问是,在我确定执行结果或以低于正常的方式显示图像的方式发送消息后,我会发出警告吗? For to complete the task I have to take a ctrl + c
为了完成任务,我必须按ctrl + c
code: 码:
var util = require('util');
var TelegramBot = require('node-telegram-bot-api');
var token = '237907874:AAG8hK1lPWi1WRlqQT2';
var bot = new TelegramBot(token, {polling: true});
var millisecondsToWait = 5000;
robot = {
"alert": function teste(message) {
var toId = '-103822200';
var resp = util.format('alerta: %s', message);
bot.sendMessage(toId, resp);
}
}
robot.alert(process.argv[2]);
in cmd i execute this code 在cmd中我执行此代码
node.exe bot.js 'text send'
Looks like some error occurs but not captured: 似乎发生了一些错误,但未捕获:
var robot = { // Don't forget about var :)
"alert": function teste(message) {
var toId = '-103822200';
var resp = util.format('alerta: %s', message);
bot.sendMessage(toId, resp)
.catch(function(error){ // Catch possible error
console.error(error);
});
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.