cdoc and some minor renames
This commit is contained in:
@ -5,19 +5,16 @@
|
||||
#include "api/DynuAPI.h"
|
||||
|
||||
int DynuAPI::refreshIp(std:: string ip) {
|
||||
|
||||
Hashmap<std::string, std::string> args;
|
||||
args.add("name", domainname);
|
||||
args.add("ipv4Address", ip);
|
||||
|
||||
std::vector<std::string> headers;
|
||||
headers.push_back("accept: application/json");
|
||||
headers.push_back("User-Agent: Mozilla/5.0 (compatible; Rigor/1.0.0; http://rigor.com)");
|
||||
headers.push_back("API-Key: " + dynuapikey);
|
||||
headers.emplace_back("accept: application/json");
|
||||
headers.emplace_back("User-Agent: Mozilla/5.0 (compatible; Rigor/1.0.0; http://rigor.com)");
|
||||
headers.emplace_back("API-Key: " + dynuapikey);
|
||||
|
||||
std::string dynurepl = request("https://api.dynu.com/v2/dns/" + domainid, true, args, headers);
|
||||
|
||||
// std::cout << "[DEBUG] api reply:: " << dynurepl << std::endl;
|
||||
const std::string dynurepl = request("https://api.dynu.com/v2/dns/" + domainid, true, args, headers);
|
||||
|
||||
if (dynurepl != "{\"statusCode\":200}") {
|
||||
return -1;
|
||||
@ -26,7 +23,7 @@ int DynuAPI::refreshIp(std:: string ip) {
|
||||
}
|
||||
}
|
||||
|
||||
void DynuAPI::init(std::string dynuApiKey, std::string domainId, std::string domainName) {
|
||||
void DynuAPI::init(const std::string& dynuApiKey, const std::string& domainId, const std::string& domainName) {
|
||||
this->dynuapikey=dynuApiKey;
|
||||
this->domainid=domainId;
|
||||
this->domainname=domainName;
|
||||
|
@ -4,7 +4,9 @@
|
||||
|
||||
#include "api/TelegramAPI.h"
|
||||
|
||||
void TelegramAPI::sendMessage(std::string text) {
|
||||
#include <Logger.h>
|
||||
|
||||
int TelegramAPI::sendMessage(const std::string& text) {
|
||||
Hashmap<std::string, std::string> args;
|
||||
args.add("chat_id", chatid);
|
||||
args.add("text", text);
|
||||
@ -12,10 +14,16 @@ void TelegramAPI::sendMessage(std::string text) {
|
||||
std::vector<std::string> headers;
|
||||
|
||||
std::string reply = request("https://api.telegram.org/bot" + apikey + "/sendmessage", false, args, headers);
|
||||
// std::cout << "[DEBUG] " << reply << std::endl;
|
||||
|
||||
unsigned const long ULONG_MAX = -1;
|
||||
if (reply.find("\"error_code\"") != ULONG_MAX) {
|
||||
Logger::error("failed to refresh the ip (Dynu API)");
|
||||
return -1;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void TelegramAPI::init(std::string apikey, std::string chatid) {
|
||||
void TelegramAPI::init(const std::string apikey, const std::string chatid) {
|
||||
this->apikey = apikey;
|
||||
this->chatid = chatid;
|
||||
}
|
||||
|
Reference in New Issue
Block a user