diff --git a/compile.sh b/compile.sh index 5c59b2d..72d3581 100755 --- a/compile.sh +++ b/compile.sh @@ -1,2 +1,2 @@ -gcc main.c -o bot $(pkgconf --libs libcurl) $(pkgconf --libs yyjson) +gcc main.c -o bot $(pkgconf --libs libcurl yyjson) ./bot YOUR_TOKEN_HERE diff --git a/main.c b/main.c index 6b73e88..fcc7abc 100644 --- a/main.c +++ b/main.c @@ -24,10 +24,11 @@ void send_message(tgbot *bot, tgmessage *message) { char *encoded_text = curl_easy_escape(bot->curl, message->text, 0); snprintf(url, sizeof(url), "%ssendMessage?chat_id=%ld&text=%s", bot->api, message->chat_id, encoded_text); - curl_free(encoded_text); curl_easy_setopt(bot->curl, CURLOPT_URL, url); curl_easy_perform(bot->curl); + + curl_free(encoded_text); } size_t write_cb(void *ptr, size_t size, size_t nmemb, char *data) {