mirror of
https://github.com/franjsco/trackmyd-bot
synced 2025-06-05 22:19:29 +02:00
small fixes
This commit is contained in:
12
server.js
12
server.js
@@ -1,3 +1,4 @@
|
|||||||
|
/* eslint-disable consistent-return */
|
||||||
const Telebot = require('telebot');
|
const Telebot = require('telebot');
|
||||||
const config = require('./config');
|
const config = require('./config');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
@@ -35,7 +36,6 @@ bot.on('/list', (msg) => {
|
|||||||
|
|
||||||
api.getDevices()
|
api.getDevices()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res.status);
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
@@ -63,18 +63,18 @@ bot.on('/position', (msg) => {
|
|||||||
|
|
||||||
api.getDevices()
|
api.getDevices()
|
||||||
.then((res) => {
|
.then((res) => {
|
||||||
console.log(res.status);
|
|
||||||
if (res.status === 200) {
|
if (res.status === 200) {
|
||||||
return res.json();
|
return res.json();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
})
|
})
|
||||||
.then((devicesJSON) => {
|
.then((json) => {
|
||||||
if (devicesJSON) {
|
if (json) {
|
||||||
const devices = [];
|
const devices = [];
|
||||||
devicesJSON.forEach((device) => {
|
json.forEach((device) => {
|
||||||
devices.push(device.name);
|
devices.push(device.name);
|
||||||
});
|
});
|
||||||
|
|
||||||
const replyMarkup = bot.keyboard([devices], { resize: true, once: true });
|
const replyMarkup = bot.keyboard([devices], { resize: true, once: true });
|
||||||
return bot.sendMessage(msg.from.id, 'Select device', { ask: 'devicePosition', replyMarkup });
|
return bot.sendMessage(msg.from.id, 'Select device', { ask: 'devicePosition', replyMarkup });
|
||||||
}
|
}
|
||||||
@@ -148,7 +148,7 @@ bot.on('/remove', (msg) => {
|
|||||||
|
|
||||||
bot.on('ask.removeDevice', (msg) => {
|
bot.on('ask.removeDevice', (msg) => {
|
||||||
api.removeDevice(msg.text)
|
api.removeDevice(msg.text)
|
||||||
.then((res) => {
|
.then(() => {
|
||||||
bot.sendMessage(msg.from.id, 'Device Deleted');
|
bot.sendMessage(msg.from.id, 'Device Deleted');
|
||||||
})
|
})
|
||||||
.catch((err) => {
|
.catch((err) => {
|
||||||
|
Reference in New Issue
Block a user