Files
iptv-downloader/discord.c
T

26 lines
886 B
C

#include "discord.h"
#include "config.h"
#include <curl/curl.h>
#include <stdio.h>
#include <string.h>
void discord_notify(const char *msg) {
if (!g_cfg.discord_webhook[0]) return;
CURL *c = curl_easy_init();
if (!c) return;
char payload[1024];
snprintf(payload, sizeof(payload),
"{\"username\":\"IPTV Downloader\","
"\"avatar_url\":\"https://i.imgur.com/ryNVNoI.png\","
"\"content\":\"%s\"}", msg);
struct curl_slist *hdrs = curl_slist_append(NULL, "Content-Type: application/json");
curl_easy_setopt(c, CURLOPT_URL, g_cfg.discord_webhook);
curl_easy_setopt(c, CURLOPT_POSTFIELDS, payload);
curl_easy_setopt(c, CURLOPT_HTTPHEADER, hdrs);
curl_easy_setopt(c, CURLOPT_TIMEOUT, 10L);
curl_easy_setopt(c, CURLOPT_WRITEFUNCTION, NULL);
curl_easy_perform(c);
curl_slist_free_all(hdrs);
curl_easy_cleanup(c);
}