added telegram api support to send message on ip update
This commit is contained in:
@ -3,7 +3,7 @@
|
||||
//
|
||||
|
||||
#include "API.h"
|
||||
#include "Hashmap.h"
|
||||
#include "../Hashmap.h"
|
||||
|
||||
#include <string>
|
||||
#include <iostream>
|
@ -7,7 +7,7 @@
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "Hashmap.h"
|
||||
#include "../Hashmap.h"
|
||||
|
||||
class API {
|
||||
public:
|
10
src/api/TelegramAPI.cpp
Normal file
10
src/api/TelegramAPI.cpp
Normal file
@ -0,0 +1,10 @@
|
||||
//
|
||||
// Created by lukas on 08.05.19.
|
||||
//
|
||||
|
||||
#include "TelegramAPI.h"
|
||||
|
||||
void TelegramAPI::sendMessage(std::string text) {
|
||||
std::string reply = request("https://api.telegram.org/bot"+ apikey + "/sendmessage?chat_id="+chatid+"&text="+text);
|
||||
std::cout << "[DEBUG] " <<reply << std::endl;
|
||||
}
|
22
src/api/TelegramAPI.h
Normal file
22
src/api/TelegramAPI.h
Normal file
@ -0,0 +1,22 @@
|
||||
//
|
||||
// Created by lukas on 08.05.19.
|
||||
//
|
||||
|
||||
#ifndef IPREFRESHER_TELEGRAMAPI_H
|
||||
#define IPREFRESHER_TELEGRAMAPI_H
|
||||
|
||||
|
||||
#include <string>
|
||||
#include "API.h"
|
||||
|
||||
class TelegramAPI : API{
|
||||
public:
|
||||
void sendMessage(std::string text);
|
||||
|
||||
private:
|
||||
std::string apikey = "717213769:AAHan1nSXhUsxLJAN1Dv8Oc0z8wqwDdYPn4";
|
||||
std::string chatid = "618154204";
|
||||
};
|
||||
|
||||
|
||||
#endif //IPREFRESHER_TELEGRAMAPI_H
|
@ -1,8 +1,9 @@
|
||||
#include <iostream>
|
||||
#include <ctime>
|
||||
|
||||
#include "API.h"
|
||||
#include "api/API.h"
|
||||
#include "Logger.h"
|
||||
#include "api/TelegramAPI.h"
|
||||
|
||||
int main(int argc, char *argv[]) {
|
||||
|
||||
@ -57,6 +58,9 @@ int main(int argc, char *argv[]) {
|
||||
|
||||
if (dynurepl != "{\"statusCode\":200}") {
|
||||
logger.logToLogfile(" [ERROR] failed to write ip to dynu api!");
|
||||
} else{
|
||||
TelegramAPI tele;
|
||||
tele.sendMessage(oldip + " moved to " + ip);
|
||||
}
|
||||
|
||||
logger.safeip(ip);
|
||||
|
Reference in New Issue
Block a user