Skip to content

Commit

Permalink
Fix status code, add detect incorrect webhook.
Browse files Browse the repository at this point in the history
  • Loading branch information
TheByKotik committed Jul 3, 2019
1 parent 73e4fe3 commit 1c83998
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
6 changes: 3 additions & 3 deletions sourcemod/configs/sbpp/discord.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
{
"Reload On" "0" // Bitflag: 0 = OnPluginStart only, 1 = OnConfigsExecuted, 2 = Before any message send, 3 = All of this.
"SteamID Version" "1" // Bitflag: 0 = Not use, 1 = SteamID3, 2 = Outdated SteamID2, 3 = Both.
"Time" "0" // Bitflag: 0 = Don't show time, 1 = Show time, 2 = Show timestamp, 3 = Show both.
"Map" "0" // Bitflag: 0 = Don't show map name, 1 = Show map name.
"Time" "0" // Bitflag: 0 = Don't show time, 1 = Show time, 2 = Show timestamp, 3 = Show both.
"Map" "0" // Bitflag: 0 = Don't show map name, 1 = Show map name.
}
"Colors"
{
Expand All @@ -23,4 +23,4 @@
"Mutes" ""
"Gags" ""
}
}
}
Binary file modified sourcemod/plugins/sbpp_discord.smx
Binary file not shown.
11 changes: 5 additions & 6 deletions sourcemod/scripting/sbpp_discord.sp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ public Plugin myinfo =
name = "SourceBans++ Discord Reports",
author = "RumbleFrog, SourceBans++ Dev Team",
description = "Listens for ban & report forward and sends it to webhook endpoints",
version = "1.7.0-36",
version = "1.7.0-38",
url = "https://sbpp.github.io"
};

Expand Down Expand Up @@ -114,7 +114,7 @@ public void SBPP_OnReportPlayer (int iReporter, int iTarget, const char[] szReas

stock void ReloadSettings ()
{
g_iSettings = 4;
g_iSettings = (1 << SteamID3);
g_iEmbedColors = { 0xDA1D87, 0x4362FA, 0x4362FA, 0x4362FA, 0xF9D942 };
SMCParser smc = new SMCParser();
smc.OnEnterSection = Settings_Parce_NewSection;
Expand Down Expand Up @@ -233,14 +233,13 @@ stock void SendEmbed (int iAuthor, int iTarget, const char[] szMessage, int iTyp
szHost );
Handle hRequest = SteamWorks_CreateHTTPRequest( k_EHTTPMethodPOST, szHook[ g_iHook[iType] ] );
if ( !hRequest || !SteamWorks_SetHTTPRequestGetOrPostParameter( hRequest, "payload_json", szJson ) || !SteamWorks_SetHTTPCallbacks( hRequest, OnHTTPRequestComplete ) || !SteamWorks_SendHTTPRequest( hRequest ) ) {
LogError( "HTTP request failed." );
delete hRequest; } }
LogError( "Create HTTP request failed." );
delete hRequest; } }
}

stock void OnHTTPRequestComplete (Handle hRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode)
{
if ( bFailure || !bRequestSuccessful && eStatusCode != k_EHTTPStatusCode200OK ) {
LogError( "HTTP request failed." ); }
if ( bFailure || !bRequestSuccessful || eStatusCode != k_EHTTPStatusCode204NoContent ) { LogError( "HTTP request failed with code: %i.%s", eStatusCode, (eStatusCode == k_EHTTPStatusCodeInvalid || eStatusCode == k_EHTTPStatusCode200OK) ? " Webhooks url can be incorrect." : "" ); }
delete hRequest;
}

Expand Down

0 comments on commit 1c83998

Please sign in to comment.