Discord Plug-in

Questions, comments, and news on the server side plug-ins and it's API
Post Reply
User avatar
FiringSquad
Sergeant
Sergeant
Posts: 849
Joined: Thu Jan 26, 2006 5:53 pm
Location: Ireland

Discord Plug-in

Post by FiringSquad »

Writing a plug-in to inform the user on their Discord client when a server is active.

This will involve the plug-in making a http call (probably POST, but whatever's easiest) to let the service know when a player joins/leaves.
At the early stages, so just doing some research.

The idea is that the plug-in can post messages (fire & forget) to my service authenticated by an api-key.
The service will then inform any subscribers if their favourite servers are active.

I'm assuming that I can link to libcurl and expect that the binary will be provided by the server.

Anybody else try to make a http call from a plug-in before?
Any gotchas/advice/examples?

A rough proposed architecture diagram is attached.
It's a bit overkill, but it's for a course project that needs to be suitable for high-availability.
I can simplify it after the project is complete (if anyone's interested)
Attachments
ProposedService.png
(110.99 KiB) Not downloaded yet
User avatar
blast
General
General
Posts: 4931
Joined: Fri Mar 21, 2003 3:49 pm
Location: playing.cxx
Contact:

Re: Discord Plug-in

Post by blast »

The bzfs API itself provides "URL jobs" which let you make HTTP requests. Use that instead of directly linking your plugin to libcurl. I have an example of that in an old plugin I wrote. There's also other examples on some Github repos.

https://bitbucket.org/blast007/bz_playe ... ayerdb.cpp
https://github.com/search?q=bz_addURLJob&type=Code
"In addition to knowing the secrets of the Universe, I can assure you that I am also quite potty trained." -Koenma (Yu Yu Hakusho)

Image
User avatar
tainn
Private First Class
Private First Class
Posts: 278
Joined: Sun Nov 18, 2018 7:25 pm
Location: phantom_zone;

Re: Discord Plug-in

Post by tainn »

Do you plan on utilizing any of the discord API libs that the communities have built and if yes, which?
User avatar
FiringSquad
Sergeant
Sergeant
Posts: 849
Joined: Thu Jan 26, 2006 5:53 pm
Location: Ireland

Re: Discord Plug-in

Post by FiringSquad »

blast wrote: Mon Jun 24, 2019 12:18 am The bzfs API itself provides "URL jobs" which let you make HTTP requests. Use that instead of directly linking your plugin to libcurl. I have an example of that in an old plugin I wrote. There's also other examples on some Github repos.

https://bitbucket.org/blast007/bz_playe ... ayerdb.cpp
https://github.com/search?q=bz_addURLJob&type=Code
Thanks blast! That's perfect.

Blast clears a path for easier development
User avatar
FiringSquad
Sergeant
Sergeant
Posts: 849
Joined: Thu Jan 26, 2006 5:53 pm
Location: Ireland

Re: Discord Plug-in

Post by FiringSquad »

tainn wrote: Mon Jun 24, 2019 8:35 am Do you plan on utilizing any of the discord API libs that the communities have built and if yes, which?
I'm creating a Discord bot that I'm hosting, which will be able to DM anyone registered with the service.

Might also be useful for server owners or admins, but I haven't thought much about that.
User avatar
allejo
Breaker of Builds
Breaker of Builds
Posts: 809
Joined: Sun Feb 17, 2008 10:01 pm
Location: /dev/null
Contact:

Re: Discord Plug-in

Post by allejo »

User avatar
FiringSquad
Sergeant
Sergeant
Posts: 849
Joined: Thu Jan 26, 2006 5:53 pm
Location: Ireland

Re: Discord Plug-in

Post by FiringSquad »

Thx :)
User avatar
Zehra
Private First Class
Private First Class
Posts: 915
Joined: Sun Oct 18, 2015 3:36 pm
Location: Within the BZFS API and Beyond it
Contact:

Re: Discord Plug-in

Post by Zehra »

You also may wish to look into OneVsOne plug-in may as well.

Some ideas to possibly look into adding after it is completed, if not currently planned.
  • Minimum player count configuration option. (a.k.a. "Don't notify player unless there is at least X players".)
  • Not including 'solo' bots in player counts.
  • Message updating up to 5 minutes after send. (Reduces the possibility of spamming the player if several servers get popular at once.)
  • Option for notifications while on servers. (Players may or may not want to be notified while they are currently on a server.)
  • "Playing 'x'" status on bot may provide some data on currently active and subscribed servers. "[] servers active out of []"
  • Option of excluding observers from notifications. (If only players are being counted, disregard this one.)
-Zehra
Those who are critical of me, I'll likely be the same of them. ~Zehra
The decisions we make are the ones we look forward too and the ones we regret. ~Zehra
There's a difference between knowing my name and knowing me, one shows respect to my name and the other is to who I am. ~Zehra

See where I've last been active at Strayers.
Visit BZList.net for a modern HTML5 server stats site.

Click here to view the 101 Leaderboard & Score Summaries Last updated 2021-01-12 (YYYY-MM-DD)
Latest 101 thread
User avatar
FiringSquad
Sergeant
Sergeant
Posts: 849
Joined: Thu Jan 26, 2006 5:53 pm
Location: Ireland

Re: Discord Plug-in

Post by FiringSquad »

Almost complete with Version 1 of this.

Came across a little snag though (I have a workaround, so no biggie).

The response from the list server, my.bzflag.org/db/, does not have an ["Access-Control-Allow-Origin" : "*"] in the headers.
This means that it cannot be loaded as a resource for another website.
My plan was to use this list to allow the user to select which servers were of interest, by reading the response from the list server.
To get around it, I can make another call from my back-end to get the resource on my behalf.

I need to submit it as a project first before releasing it to the public here.
Post Reply