AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Snippets and Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=112)
-   -   [SNIPPET] SteamWorks to Slack (webhook) (https://forums.alliedmods.net/showthread.php?t=292104)

ImACow 12-29-2016 15:35

[SNIPPET] SteamWorks to Slack (webhook)
 
Requires SteamWorks

May be useful to some.

PHP Code:

public void SendToSlack(const char[] cMessage)
{
    
char[] sFormat = new char[2048];
    
Format(sFormat2048"{\"channel\": \"#sourcemod\", \"username\": \"%s\", \"text\": \"%s\", \"icon_emoji\": \":speech_balloon:\"}""CSGO Server"cMessage);

    
Handle hHTTP_request SteamWorks_CreateHTTPRequest(k_EHTTPMethodPOST"https://hooks.slack.com/services/...");
    
SteamWorks_SetHTTPRequestRawPostBody(hHTTP_request"application/json"sFormatstrlen(sFormat));
    if (
hHTTP_request == null || !SteamWorks_SetHTTPCallbacks(hHTTP_requestSlack_Callback) || !SteamWorks_SendHTTPRequest(hHTTP_request))
    {
        
PrintToServer("[SendToSlack] SendToSlack failed to fire");
        
delete hHTTP_request;
    }
}

public 
Slack_Callback(Handle hRequestbool bFailurebool bRequestSuccessfulEHTTPStatusCode eStatusCode
{
    
char cActionName[64];
    
cActionName "Slack_Callback";
    if (!
bFailure && bRequestSuccessful)
    {
        switch (
eStatusCode)
        {
            case 
200:
            {
                
//all gud
            
}
            default:
            {
                
PrintToServer("[%s] failed with code [%i]"cActionNameeStatusCode);
                
SteamWorks_GetHTTPResponseBodyCallback(hRequestPrint_Response);
            }
        }
    }
    
delete hRequest;
}
public 
Print_Response(const char[] sData)
{
    
PrintToServer("[Print_Response] %s"sData);



Neuro Toxin 12-29-2016 19:07

Re: [SNIPPET] SteamWorks to Slack (webhook)
 
What's Slack?

Pelipoika 12-29-2016 19:54

Re: [SNIPPET] SteamWorks to Slack (webhook)
 
Quote:

Originally Posted by Neuro Toxin (Post 2481798)
What's Slack?

https://slack.com/

hadesownage 12-30-2016 11:15

Re: [SNIPPET] SteamWorks to Slack (webhook)
 
People is using Discord, not Slack.
If you can convert this to work on Discord will be great!

Mitchell 12-30-2016 12:42

Re: [SNIPPET] SteamWorks to Slack (webhook)
 
Quote:

Originally Posted by hadesownage (Post 2482010)
People is using Discord, not Slack.
If you can convert this to work on Discord will be great!

Gamers use Discord,
Developers use Slack,
Old people (psychonic) use IRC.

Pelipoika 12-30-2016 13:11

Re: [SNIPPET] SteamWorks to Slack (webhook)
 
Quote:

Originally Posted by Mitchell (Post 2482059)
Gamers use Discord,
Developers use Slack,
Old people (psychonic) use IRC.

http://i.imgur.com/ZN8BEu6.png

8guawong 12-30-2016 22:08

Re: [SNIPPET] SteamWorks to Slack (webhook)
 
damn i'm old

Phire 12-31-2016 00:30

Re: [SNIPPET] SteamWorks to Slack (webhook)
 
Thanks for posting this, really helpful.

m_bNightstalker 01-01-2017 20:42

Re: [SNIPPET] SteamWorks to Slack (webhook)
 
Maybe check this one https://github.com/casual-trade-and-...alladmin-slack

ImACow 01-02-2017 10:30

Re: [SNIPPET] SteamWorks to Slack (webhook)
 
uses CURL, which is poorly supported around these forums.
While SteamWorks kicks ass, and KyleS even more


All times are GMT -4. The time now is 18:55.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.