Re: Discord webook integration
By: Hunter-Z to All on Sat Oct 23 2021 07:27 pm
Hello. I used to run a Synchronet BBS in the mid-late 1990s, and set up a modern version in a WinXP VirtualBox VM in 2015 for fun. I recently blew the dust off of this because some friends on Discord were interested in experiencing the BBS thing in a private setting.
Since we're using Discord and Synchronet is now heavy into JavaScript, I thought I'd try hooking the two together. I've had limited success using an HTTPRequest from Synchronet's http.js to send POST requests to a Discord webhook URL, but I've run into some issues and limitations that I could use some advice on.
I should mention up-front that I'm a novice at JavaScript, so I'm probably going about this all wrong. My native language is C++! +--------------------------+
|Logon/logoff notifications|
+--------------------------+
The first thing I tried to do was have Synchronet tell people on Discord when someone logs on or off. Logon works great, even reporting the user and node number. Logoff, on the other hand, is problematic: It seems that regardless of whether I use the fixed event or an on-logoff event-driven external program entry, Synchronet terminates my JavaScript code before it can send the POST request! As an ugly hack, I was able to get it working by having a fixed logoff event call a .BAT file, which in turn calls jsexec -x, but there has to be a better way?
For non-interactive logout event, you want to set SCFG->External Programs->Fixed Events->Logout Event to execute your script (e.g. "?logout"). I tested this with a simple logout.js to logs some lines, runs a loop, sleeps 1 second, the complete script ran without getting terminated. One thing that might help you is to include "js.auto_terminate = false" in the beginning of your script.
I'm also wondering if this is the best way to do any of this in general. What about just creating custom logon/logoff *modules* that wrap the default ones or something?
Not really sure what you're asking here. There is no "default" logout event.
+-------------------------+
|BBS up/down notifications|
+-------------------------+
I'd love to have something notify Discord when the BBS goes up or down, but there isn't an obvious way to do this either. I was able to get a "BBS up" notification to work by creating a timed even that is set to run on *no* days of the week, and to run on (re)init, but this again feels like a hack.
That's how I'd do it. But ideally, a BBS is a stable server (like a web server) and shouldn't need to be telling its users when it's online or offline. It should *always* (or almost alway) be online.
I also don't see any way at all to trigger a "BBS down" event. I'm wondering if maybe I should just handle this externally to Synchronet, like maybe via a Windows Task Manager job or something?
Sure. Or just make a script that both sends your status update and terminates sbbs.
+------------------------------+
|External Program notifications|
+------------------------------+
Edit: Forgot to mention this. It would be great if I could somehow trigger a script when someone enters a door program, without having to edit every door's configuration to integrate it via a batch file or whatever.
Any advice/thoughts appreciated.
Look at exec/prextrn.js and postxtrn.js.
--
digital man
Rush quote #47:
All of us get lost in the darkness, dreamers learn to steer by the stars
Norco, CA WX: 73.5øF, 53.0% humidity, 1 mph SSW wind, 0.00 inches rain/24hrs ---
þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net