#include <amxmodx>
#include <sockets>
#define HOST "api.telegram.org"
#define MESSAGE "ТЕСТ"
#define CHAT_ID ""
#define TOKEN ""
new count;
public plugin_init()
register_srvcmd("curl", "send");
public send()
{
new err;
new SockId = socket_open(HOST, 443, SOCKET_TCP, err);
if(err == 0)
{
new szSendBuffer[250];
//formatex(szSendBuffer, charsmax(szSendBuffer), "GET bot%s/sendMessage?chat_id=%s&text=%s HTTP/1.1^nUser-Agent: curl/7.38.0^nHost: %s Accept: */*^n^n", TOKEN, CHAT_ID, MESSAGE, HOST);
formatex(szSendBuffer, charsmax(szSendBuffer), "GET /bot%s/sendMessage?chat_id=%s&text=%s HTTP/1.1^nUser-Agent: curl^nHost: %s^r^n^r^n", TOKEN, CHAT_ID, MESSAGE, HOST)
socket_send(SockId, szSendBuffer, charsmax(szSendBuffer));
log_to_file("tgsend.log", "%s", szSendBuffer)
count = 0;
set_task(1.0, "socketAnswer", SockId, .flags = "b");
}
}
public socketAnswer(id)
{
if(socket_change(id, 50000))
{
new szData[1024];
socket_recv(id, szData, charsmax(szData));
server_print("-> %s", szData);
socket_close(id);
remove_task(id);
}
else if(++count == 10)
{
socket_close(id);
remove_task(id);
}
}