Page 1 of 1

Discord Plug-in

Posted: Sun Jun 23, 2019 10:47 pm
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)

Re: Discord Plug-in

Posted: Mon Jun 24, 2019 12:18 am
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

Re: Discord Plug-in

Posted: Mon Jun 24, 2019 8:35 am
by tainn
Do you plan on utilizing any of the discord API libs that the communities have built and if yes, which?

Re: Discord Plug-in

Posted: Mon Jun 24, 2019 11:25 am
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

Re: Discord Plug-in

Posted: Mon Jun 24, 2019 11:35 am
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.

Re: Discord Plug-in

Posted: Tue Jun 25, 2019 12:07 am
by allejo

Re: Discord Plug-in

Posted: Tue Jun 25, 2019 8:21 pm
by FiringSquad
Thx :)

Re: Discord Plug-in

Posted: Wed Jun 26, 2019 10:03 pm
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

Re: Discord Plug-in

Posted: Mon Aug 19, 2019 6:29 pm
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.