Jump to content

Showcase: @requests forwarded to discord

Recommended Posts

Story Time:

A lot of players run into problems. They disconnected in an instance, they bought the wrong item, someone is being a nuisance in battlegrounds. After cursing, they usually type `@request`. But alas, none of the GMs you hired are online! You need to dock their pay. The message is lost in the void.

Until now.

Discord has support for webhooks, which is a way to associate callbacks to HTTP requests. Their developer docs for webhooks can be found here. Basically, you can send a POST to your discord webhook url, and the contents will be printed to the associated channel. 


When someone uses `@request`, the message is sent from the map server to the character server, which then sends it back to all map servers, and the map servers send the message to all connected GMs. 

Because it sends it to the character server, we're able to send the POST request from the character server. This helps performance, since the map server is constantly doing things and the character server generally uses less resources. 

"That's great! But how do we send this POST request? Do I need a stamp?"

If you're on Linux, there's a great command line tool called `curl`. It's mostly used to download files from a server, but it also has support for all other HTTP methods.

"Command line? How do we put it in rathena?"

Curl also comes with a library called libcurl that we can use in c/c++ programs! 

"I see, so we use libcurl to send the message to the discord webhook!"


How it looks:



Two config options are added in this patch: gm_whisp_webhook and gm_whisp_webhook_url

This makes a change to configure, and adds a new flag. You need to add --with-lcurl to your arguments. Example: ./configure --enable-prere --enable-vip --enable-packetver=20170614 --with-lcurl


This only works on linux. I don't run rAthena servers on windows, and neither should you. (personal opinion)

You need to install libcurl-devel. On some OSes it could be called something else; on Ubuntu, it's libcurl4-openssl-dev.

Don't ask me for a lot of help if you can't get it to work. This is supposed to be a showcase, but I'm giving the code out.

I made this in a day, it's not the greatest code. Initializing curl and cleaning up on every call is not the greatest, but unless you are getting 100 requests a minute, it should be ok for now.

Eventually, I want to add it to src/common or something. But that'll happen in a future weekend.


The code is here: https://pastebin.com/Z82M9ssf

Edited by nitrous
  • Upvote 7
  • Love 1
  • MVP 1
  • Like 2
Link to comment
Share on other sites

wow it's good add on, there is this topic that can send chat in game to discord and vice versa, discord is hot commodity for gamer nowadays and it will be goodies if real time message  can be made then on server side instead hooking on client, rep  up for you

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Create New...

Important Information

By using this site, you agree to our Terms of Use and Privacy Policy.