/
forstalang22.sp
76 lines (60 loc) · 1.46 KB
/
forstalang22.sp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include <sourcemod>
#include <cURL>
public Plugin myinfo =
{
name = "Forstalang22 CS-bot",
author = "Me",
description = "Posts stats to Slack",
version = "1.0",
url = "http://forstalang22.slack.com/"
};
public void OnPluginStart()
{
char data[512];
CreateHandledData(data, sizeof(data));
PostData(data);
//PrintToServer(data);
}
void PostData(const char[] data)
{
char url[256];
url = ""
Handle curl = curl_easy_init();
if(curl == null) return;
SetUrl(curl, url);
SetData(curl, data);
curl_easy_perform_thread(curl, RequestFinished);
}
void SetUrl(Handle curl, const char[] url)
{
curl_easy_setopt_string(curl, CURLOPT_URL, url);
curl_easy_setopt_int(curl, CURLOPT_SSL_VERIFYPEER, 0);
}
void SetData(Handle curl, const char[] data)
{
curl_easy_setopt_string(curl, CURLOPT_POSTFIELDS, data);
}
public int RequestFinished(Handle curl, CURLcode code)
{
if(code != CURLE_OK) {
char error[128];
curl_get_error_buffer(curl, error, sizeof(error));
LogError("[Forstalang22 Slack] %s", error);
}
delete curl;
}
void CreateHandledData(char[] data, int length)
{
// int reportId = notification.ReadCell();
char admin[MAX_NAME_LENGTH] = "hej"
int reportId = 1
// notification.ReadString(admin, sizeof(admin));
Format(data,
length,
"payload={\
\"text\":\"*%s* from counterstrike #%i. :thumbsup:\",\
\"icon_emoji\":\":cs:\", \"channel\":\"#lanparty\",\
\"username\":\"CS-bot\"}",
admin,
reportId);
}