Raised This Month: $ Target: $400
 0% 

[SNIPPET] SteamWorks to Slack (webhook)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 12-29-2016 , 15:35   [SNIPPET] SteamWorks to Slack (webhook)
Reply With Quote #1

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);

__________________

Last edited by ImACow; 12-29-2016 at 15:40.
ImACow is offline
Neuro Toxin
Veteran Member
Join Date: Oct 2013
Location: { closing the void; }
Old 12-29-2016 , 19:07   Re: [SNIPPET] SteamWorks to Slack (webhook)
Reply With Quote #2

What's Slack?
__________________
Neuro Toxin is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 12-29-2016 , 19:54   Re: [SNIPPET] SteamWorks to Slack (webhook)
Reply With Quote #3

Quote:
Originally Posted by Neuro Toxin View Post
What's Slack?
https://slack.com/
__________________
Pelipoika is offline
hadesownage
AlliedModders Donor
Join Date: Jun 2013
Location: Romania, Iași
Old 12-30-2016 , 11:15   Re: [SNIPPET] SteamWorks to Slack (webhook)
Reply With Quote #4

People is using Discord, not Slack.
If you can convert this to work on Discord will be great!
hadesownage is offline
Send a message via Yahoo to hadesownage Send a message via Skype™ to hadesownage
Mitchell
~lick~
Join Date: Mar 2010
Old 12-30-2016 , 12:42   Re: [SNIPPET] SteamWorks to Slack (webhook)
Reply With Quote #5

Quote:
Originally Posted by hadesownage View Post
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.
Mitchell is offline
Pelipoika
Veteran Member
Join Date: May 2012
Location: Inside
Old 12-30-2016 , 13:11   Re: [SNIPPET] SteamWorks to Slack (webhook)
Reply With Quote #6

Quote:
Originally Posted by Mitchell View Post
Gamers use Discord,
Developers use Slack,
Old people (psychonic) use IRC.
__________________

Last edited by Pelipoika; 12-30-2016 at 13:12.
Pelipoika is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-30-2016 , 22:08   Re: [SNIPPET] SteamWorks to Slack (webhook)
Reply With Quote #7

damn i'm old
__________________
8guawong is offline
Phire
Junior Member
Join Date: May 2016
Location: Scotland, United Kingdom
Old 12-31-2016 , 00:30   Re: [SNIPPET] SteamWorks to Slack (webhook)
Reply With Quote #8

Thanks for posting this, really helpful.
__________________
root@phire:~# sudo apt-get install life
Reading package lists... Done
Building dependency tree
Reading state information... Done
E: Unable to locate package life
Phire is offline
m_bNightstalker
Senior Member
Join Date: Jan 2015
Location: JWD
Old 01-01-2017 , 20:42   Re: [SNIPPET] SteamWorks to Slack (webhook)
Reply With Quote #9

Maybe check this one https://github.com/casual-trade-and-...alladmin-slack
m_bNightstalker is offline
ImACow
AlliedModders Donor
Join Date: Feb 2015
Old 01-02-2017 , 10:30   Re: [SNIPPET] SteamWorks to Slack (webhook)
Reply With Quote #10

uses CURL, which is poorly supported around these forums.
While SteamWorks kicks ass, and KyleS even more
__________________
ImACow is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 02:14.


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