2
2
#include < amxmisc>
3
3
#include < fakemeta>
4
4
5
- #include < grip >
5
+ #include < easy_http >
6
6
#include < ChatAdditions>
7
7
8
8
#pragma tabsize 4
@@ -128,7 +128,7 @@ ReadFolder(deleteTime, logPath[]) {
128
128
new fileTime
129
129
130
130
if (dirHandle) {
131
- do
131
+ do
132
132
{
133
133
if (logFile[0 ] == ' .' ) {
134
134
continue
@@ -182,7 +182,7 @@ Create_CVars() {
182
182
0 - The logs won't be deleted.^n \
183
183
> 0 - The logs will be deleted at the time inserted." ,
184
184
.has_min = true , .min_val = 0 .0
185
- ),
185
+ ),
186
186
ca_log_autodelete_time
187
187
)
188
188
}
@@ -198,11 +198,17 @@ public plugin_natives() {
198
198
}
199
199
200
200
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
202
202
}
203
203
204
204
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
206
212
}
207
213
208
214
public ClCmd_Say (const id) {
@@ -354,9 +360,9 @@ static CheckUpdate() {
354
360
if (strcmp (CA_VERSION, " CA_VERSION" ) == 0 || contain (CA_VERSION, " ." ) == - 1 ) // ignore custom builds
355
361
return
356
362
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`)." )
360
366
361
367
return
362
368
}
@@ -365,51 +371,45 @@ static CheckUpdate() {
365
371
}
366
372
367
373
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" )
381
375
}
382
376
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
+
384
386
new response[8192 ]
385
- grip_get_response_body_string ( response, charsmax (response))
387
+ ezhttp_get_data (request_id, response, charsmax (response))
386
388
387
389
if (contain (response, " tag_name" ) == - 1 ) {
388
390
CA_Log (logLevel_Warning, " > Wrong response! (don't contain `tag_name`). res=`%s `" , response)
389
391
return
390
392
}
391
393
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!" )
397
397
goto END
398
398
}
399
399
400
400
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))
402
402
403
403
if (CmpVersions (CA_VERSION, tag_name) >= 0 )
404
404
goto END
405
405
406
406
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))
408
408
409
409
NotifyUpdate (tag_name, html_url)
410
410
411
411
END:
412
- grip_destroy_json_value (json)
412
+ ezjson_free (json)
413
413
}
414
414
415
415
static NotifyUpdate (const newVersion[], const URL[]) {
0 commit comments