trackmyd-bot/src/utils.js

25 lines
684 B
JavaScript
Raw Permalink Normal View History

2019-02-22 17:32:06 +01:00
const templates = require('./templates');
function sendErrorMessage(error, msgBot) {
switch (error.message) {
case 'DevicesNotFound':
msgBot.reply.text(templates.devicesNotFound());
break;
case 'DeviceNotFound':
msgBot.reply.text(templates.devicesNotFound(msgBot.text));
break;
2019-02-23 23:21:39 +01:00
case 'PositionNotFound':
msgBot.reply.text(templates.positionNotFound());
break;
2019-02-22 17:32:06 +01:00
default:
msgBot.reply.text(templates.error());
2019-02-22 10:02:51 +01:00
}
2019-02-21 14:54:46 +01:00
}
2019-02-22 17:32:06 +01:00
function convertTimestamp(timestamp) {
return new Date(timestamp * 1000).toISOString().slice(0, 19);
2019-02-21 14:54:46 +01:00
}
2019-02-22 17:32:06 +01:00
module.exports.convertTimestamp = convertTimestamp;
module.exports.sendErrorMessage = sendErrorMessage;