Skip to content

Commit 1ed9568

Browse files
authored
replace grip.inc -> easy_http.inc (#330)
* replace `grip.inc` -> `easy_http.inc` * update README
1 parent efdf22b commit 1ed9568

File tree

4 files changed

+920
-1102
lines changed

4 files changed

+920
-1102
lines changed

.github/README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ Rich API capabilities allow the system to connect any functionality (work with p
5050
- [ReGameDLL](https://github.com/s1lentq/ReGameDLL_CS) installed;
5151
- Installed AMXModX ([`v1.9`](https://www.amxmodx.org/downloads-new.php) or [`v1.10`](https://www.amxmodx.org/downloads-new.php?branch=master));
5252
- Installed [ReAPI](https://github.com/s1lentq/reapi) module (optional, but not required);
53+
- Installed [AmxxEasyHttp](https://github.com/Next21Team/AmxxEasyHttp) module (optional, but not required);
5354

5455
## Installation
5556
- [Download the latest](https://github.com/ChatAdditions/ChatAdditions_AMXX/releases/latest) stable version from the release section.

cstrike/addons/amxmodx/scripting/ChatAdditions/ChatAdditions_Core.sma

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include <amxmisc>
33
#include <fakemeta>
44

5-
#include <grip>
5+
#include <easy_http>
66
#include <ChatAdditions>
77

88
#pragma tabsize 4
@@ -128,7 +128,7 @@ ReadFolder(deleteTime, logPath[]) {
128128
new fileTime
129129

130130
if (dirHandle) {
131-
do
131+
do
132132
{
133133
if (logFile[0] == '.') {
134134
continue
@@ -182,7 +182,7 @@ Create_CVars() {
182182
0 - The logs won't be deleted.^n \
183183
> 0 - The logs will be deleted at the time inserted.",
184184
.has_min = true, .min_val = 0.0
185-
),
185+
),
186186
ca_log_autodelete_time
187187
)
188188
}
@@ -198,11 +198,17 @@ public plugin_natives() {
198198
}
199199

200200
public ModuleFilter(const library[], LibType: type) {
201-
return strcmp("grip", library) == 0 ? PLUGIN_HANDLED : PLUGIN_CONTINUE
201+
return strcmp("easy_http", library) == 0 ? PLUGIN_HANDLED : PLUGIN_CONTINUE
202202
}
203203

204204
public NativeFilter(const nativeName[], index, trap) {
205-
return strncmp(nativeName, "grip_", 5) == 0 ? PLUGIN_HANDLED : PLUGIN_CONTINUE
205+
if (strncmp(nativeName, "ezhttp_", 7) == 0)
206+
return PLUGIN_HANDLED
207+
208+
if (strncmp(nativeName, "ezjson_", 7) == 0)
209+
return PLUGIN_HANDLED
210+
211+
return PLUGIN_CONTINUE
206212
}
207213

208214
public ClCmd_Say(const id) {
@@ -354,9 +360,9 @@ static CheckUpdate() {
354360
if (strcmp(CA_VERSION, "CA_VERSION") == 0 || contain(CA_VERSION, ".") == -1) // ignore custom builds
355361
return
356362

357-
if (is_module_loaded("grip") == -1) {
358-
CA_Log(logLevel_Warning, "The `GRip` module is not loaded! The new version cannot be verified.")
359-
CA_Log(logLevel_Warning, "Please install GRip: `https://github.com/In-line/grip` or disable update checks (`ca_update_notify `0`).")
363+
if (is_module_loaded("Amxx Easy Http") == -1) {
364+
CA_Log(logLevel_Warning, "The `AmxxEasyHttp` module is not loaded! The new version cannot be verified.")
365+
CA_Log(logLevel_Warning, "Please install AmxxEasyHttp: `https://github.com/Next21Team/AmxxEasyHttp` or disable update checks (`ca_update_notify `0`).")
360366

361367
return
362368
}
@@ -365,51 +371,45 @@ static CheckUpdate() {
365371
}
366372

367373
static RequestNewVersion(const link[]) {
368-
new GripRequestOptions: options = grip_create_default_options()
369-
new GripBody: body = grip_body_from_string("")
370-
371-
grip_request(
372-
link,
373-
body,
374-
GripRequestTypeGet,
375-
"@RequestHandler",
376-
options
377-
)
378-
379-
grip_destroy_body(body)
380-
grip_destroy_options(options)
374+
ezhttp_get(link, "@RequestHandler")
381375
}
382376

383-
@RequestHandler() {
377+
@RequestHandler(EzHttpRequest: request_id) {
378+
if (ezhttp_get_error_code(request_id) != EZH_OK) {
379+
new error[64]
380+
ezhttp_get_error_message(request_id, error, charsmax(error))
381+
server_print("Response error: %s", error)
382+
return
383+
}
384+
385+
384386
new response[8192]
385-
grip_get_response_body_string(response, charsmax(response))
387+
ezhttp_get_data(request_id, response, charsmax(response))
386388

387389
if (contain(response, "tag_name") == -1) {
388390
CA_Log(logLevel_Warning, " > Wrong response! (don't contain `tag_name`). res=`%s`", response)
389391
return
390392
}
391393

392-
static errorBuffer[1024]
393-
new GripJSONValue: json = grip_json_parse_string(response, errorBuffer, charsmax(errorBuffer))
394-
395-
if (json == Invalid_GripJSONValue) {
396-
CA_Log(logLevel_Warning, " > Can't parse response JSON! (error=`%s`)", errorBuffer)
394+
new EzJSON: json = ezjson_parse(response)
395+
if (json == EzInvalid_JSON) {
396+
CA_Log(logLevel_Warning, " > Can't parse response JSON!")
397397
goto END
398398
}
399399

400400
new tag_name[32]
401-
grip_json_object_get_string(json, "tag_name", tag_name, charsmax(tag_name))
401+
ezjson_object_get_string(json, "tag_name", tag_name, charsmax(tag_name))
402402

403403
if (CmpVersions(CA_VERSION, tag_name) >= 0)
404404
goto END
405405

406406
new html_url[256]
407-
grip_json_object_get_string(json, "html_url", html_url, charsmax(html_url))
407+
ezjson_object_get_string(json, "html_url", html_url, charsmax(html_url))
408408

409409
NotifyUpdate(tag_name, html_url)
410410

411411
END:
412-
grip_destroy_json_value(json)
412+
ezjson_free(json)
413413
}
414414

415415
static NotifyUpdate(const newVersion[], const URL[]) {

0 commit comments

Comments
 (0)