bettercap/_example/telegram.js
2021-04-08 22:13:57 +02:00

18 lines
No EOL
586 B
JavaScript

function sendMessage(message) {
log(message);
var url = 'https://api.telegram.org/bot' + telegramToken +
'/sendMessage?chat_id=' + telegramChatId +
'&text=' + http.Encode(message);
var resp = http.Get(url, {});
if( resp.Error ) {
log("error while running sending telegram message: " + resp.Error.Error());
}
}
function sendPhoto(path) {
var url = 'https://api.telegram.org/bot' + telegramToken + '/sendPhoto';
var cmd = 'curl -s -X POST "' + url + '" -F chat_id=' + telegramChatId + ' -F photo="@' + path + '"';
run("!"+cmd);
}