Created
August 27, 2019 09:04
-
-
Save chernysh2909/5e0ab285266409e74851e7874628c971 to your computer and use it in GitHub Desktop.
send photo to telegram JS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let request = require('request'); | |
let fs = require('fs'); | |
let FormData = require('form-data'); | |
let tokken = '828922035:AAGr4ZF1yoISDiKOFt_rBHi1k6q8Cz-uuHk'; | |
let chatId = -1001320778442; | |
let url = 'https://api.telegram.org/bot' + tokken + '/sendPhoto'; | |
var formData = { | |
chat_id: chatId, | |
photo: fs.createReadStream(__dirname + '/alert_images/photo_2019-07-23_17-12-31.jpg'), | |
}; | |
request.post({url:url, formData: formData}, function optionalCallback(err, httpResponse, body) { | |
if (err) { | |
return console.error('upload failed:', err); | |
} | |
console.log('Upload successful! Server responded with:', body); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment