void SendMessage(SYSTEMTIME localTime) {
CURL* curl;
CURLcode res;
std::wstringstream fmt;
fmt << ((localTime.wDay < 10) ? (_T("0")) : (_T(""))) << localTime.wDay << _T(".")
<< ((localTime.wMonth < 10) ? (_T("0")) : (_T(""))) << localTime.wMonth << _T(".") << localTime.wYear << _T(" ")
<< localTime.wHour << _T(":") << localTime.wMinute << std::endl;
TCHAR* fields = NULL;
fmt >> fields;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL,
"https://api.telegram.org/bot{MyToken}/sendMessage");
curl_easy_setopt(curl, CURLOPT_HTTPPOST, 1);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, _tcscat_s(_T("chat_id={MyChatId}&text="), 23, fields));
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
}
void SendMessage(SYSTEMTIME localTime) {
CURL* curl;
CURLcode res;
std::stringstream fmt;
fmt << ((localTime.wDay < 10) ? ("0") : ("")) << localTime.wDay << "." << ((localTime.wMonth < 10) ? ("0") : (""))
<< localTime.wMonth << "." << localTime.wYear << " " << localTime.wHour << ":" << localTime.wMinute << std::endl;
char* fields = nullptr;
fmt >> fields;
curl = curl_easy_init();
if (curl) {
curl_easy_setopt(curl, CURLOPT_URL,
"https://api.telegram.org/bot{MyToken}/sendMessage");
curl_easy_setopt(curl, CURLOPT_HTTPPOST, 1);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYPEER, 0L);
curl_easy_setopt(curl, CURLOPT_SSL_VERIFYHOST, 0L);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, strcat("chat_id={MyChatId}&text=", fields));
res = curl_easy_perform(curl);
curl_easy_cleanup(curl);
}
}