johnlauer/serial-port-json-server

const telegramAuthToken = '<5909370411:AAFdvgWEkWAeEG9asMVIZ3E7ek13vBIJgO0'; var requestmaker = require('request'); app.use(express.json()); app.post('/' + telegramAuthToken, function(request, response) { response.set('Content-Type', 'application/json'); console.log(request.body); const userText = request.body.message.text; const chatId = request.body.message.chat.id; sendTextToTelegram(chatId, userText); response.end(); function sendTextToTelegram(chatId, message) { message = encodeURI(message); const response = `https://api.telegram.org/bot${telegramAuthToken}/sendMessage?chat_id=${chatId}&parse_mode=Markdown&text=${message}`; console.log(response); requestmaker(response); } });

ESTHERTERSEN opened this issue · 0 comments

const telegramAuthToken = '<5909370411:AAFdvgWEkWAeEG9asMVIZ3E7ek13vBIJgO0'; var requestmaker = require('request'); app.use(express.json()); app.post('/' + telegramAuthToken, function(request, response) { response.set('Content-Type', 'application/json'); console.log(request.body); const userText = request.body.message.text; const chatId = request.body.message.chat.id; sendTextToTelegram(chatId, userText); response.end(); function sendTextToTelegram(chatId, message) { message = encodeURI(message); const response = `https://api.telegram.org/bot${telegramAuthToken}/sendMessage?chat_id=${chatId}&parse_mode=Markdown&text=${message}`; console.log(response); requestmaker(response); } });