• Discord webook integration

    From Hunter-Z@VERT to All on Sat Oct 23 19:27:14 2021
    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?

    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? Any suggestions?

    +-------------------------+
    |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.

    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?

    Any advice/thoughts appreciated.

    Thanks,
    - Ben S. / HunterZ

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From Tracker1@VERT/TRN to Hunter-Z on Sun Oct 24 06:02:29 2021
    On 10/23/21 7:27 PM, Hunter-Z wrote:
    +-------------------------+
    |BBS up/down notifications|
    +-------------------------+
    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?

    Down notifications are best done from another system... You can have
    that system poll every N minutes to see if you're up, and send a down notification if it fails... more complexity could be to check every 5 mninutes, then check again every 30s and 5 fails in a row, fire teh notification.


    +------------------------------+
    |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.

    Edit your command shell to use the xtrn_sec.js module for doors, then
    modify that module.... that would probably be the easiest path... I
    think that is the name of it, it may just be xtrn.js ... I don't recall
    if there's another even that triggers before every door.
    --
    Michael J. Ryan - tracker1@roughneckbbs.com
    ---
    þ Synchronet þ Roughneck BBS - roughneckbbs.com
  • From Hunter-Z@VERT to All on Sun Oct 24 08:59:39 2021
    Re: Discord webook integration
    By: Hunter-Z to All on Sat Oct 23 2021 07:27 pm

    (oops, typo in subject that I can't seem to edit - meant to say "webhook")

    Update: Got everything working that I wanted to do, via a plethora of different hacks. Below is info on the additional pieces I implemented since my initial post.

    BBS down:

    I found a tool called something like Bill2's Process Monitor that can monitor processes and take various actions. I configured this to run a "BBS down" notification script when Synchronet's process goes away.

    This works great, except it doesn't seem to fire fast enough when the whole VM is shutting down / rebooting, so I also added a call to the notification script as a shutdown entry in WinXP's group policy editor.

    External program run:

    Turns out that Synchronet's modopts.ini allows you to define optional script hooks for when a user enters and exits an external program. This is great, and I wish there were either more of these, or more event triggers in the config utility (it's weird that both solutions coexist, but better than having no options at all!).

    I wasn't able to make heads or tails of the wiki documentation on js.exec() regarding passing of parameters (which is how I tell my webhook script what to post to Discord), but I found an example of doing it via load() that works fine.

    Summary:

    In the end, it feels pretty hacky that I'm using no less than 5 different ways to trigger events (fixed events in SBBS config, "timed" even in SBBS config, modopts.ini script hooks, external process monitor, Windows group policy). It would be ideal for Synchronet to provide a unified means to implement triggers for all of these cases, but it is what it is, and at least I accomplished my goals!

    - Ben S. / HunterZ

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From MRO@VERT/BBSESINF to all on Sun Oct 24 10:38:11 2021
    Re: Re: Discord webook integration
    By: Tracker1 to Hunter-Z on Sun Oct 24 2021 06:02 am

    On 10/23/21 7:27 PM, Hunter-Z wrote:
    +-------------------------+
    |BBS up/down notifications|
    +-------------------------+
    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?

    Down notifications are best done from another system... You can have
    that system poll every N minutes to see if you're up, and send a down notification if it fails... more complexity could be to check every 5 mninutes, then check again every 30s and 5 fails in a row, fire teh notification.


    +------------------------------+
    |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.

    Edit your command shell to use the xtrn_sec.js module for doors, then
    modify that module.... that would probably be the easiest path... I
    think that is the name of it, it may just be xtrn.js ... I don't recall
    if there's another even that triggers before every door.
    --
    Michael J. Ryan - tracker1@roughneckbbs.com




    siteuptime.com is something i've used for MANY years and it's pretty accurate. it checks your service and if it's down you know.
    ---
    þ Synchronet þ ::: BBSES.info - free BBS services :::
  • From MRO@VERT/BBSESINF to Hunter-Z on Sun Oct 24 11:10:58 2021
    Re: Discord webhook integration
    By: Hunter-Z to All on Sun Oct 24 2021 08:59 am

    Update: Got everything working that I wanted to do, via a plethora of different hacks. Below is info on the additional pieces I implemented since my initial post.

    BBS down:

    your bbs probably won't go down.
    i would suggest making the computer reboot once a day, though.

    policy). It would be ideal for Synchronet to provide a unified means to implement triggers for all of these cases, but it is what it is, and at least I accomplished my goals!

    I don't know if other people need this, but you can request it. or do it yourself with scripting.
    ---
    þ Synchronet þ ::: BBSES.info - free BBS services :::
  • From Hunter-Z@VERT to MRO on Sun Oct 24 11:14:28 2021
    Re: Discord webhook integration
    By: MRO to Hunter-Z on Sun Oct 24 2021 11:10 am

    your bbs probably won't go down.
    i would suggest making the computer reboot once a day, though.

    It won't go down due to failure, but I've been cycling/downing it a lot to make changes, add things, etc. It's also running in a VM on my HTPC, so it's possible that I will need to occasionally reboot the host or temporarily stop the VM for various other reasons (maintenance etc.).

    I don't know if other people need this, but you can request it. or do it yourself with scripting.

    Is this something that would be worth writing a Git issue on, or would it just waste everyone's time?

    My final thoughts are:
    - It would be nice to have a canonical/supported way to script an action when Synchronet shuts down.
    - It would be nice to see some design consolidation of scripting triggers, as having to dig through module selections, fixed events, on-init-via-timed-menu events, event-triggered external programs, modopts.ini script hooks, etc. to find the best way to do something makes for a steep learning curve - especially when the answer is different depending on what you're trying to accomplish.

    Thanks,
    - Ben S. / HunterZ

    ---
    þ Synchronet þ Vertrauen þ Home of Synchronet þ [vert/cvs/bbs].synchro.net
  • From MRO@VERT/BBSESINF to Hunter-Z on Sun Oct 24 13:35:57 2021
    Re: Discord webhook integration
    By: Hunter-Z to MRO on Sun Oct 24 2021 11:14 am

    My final thoughts are:
    - It would be nice to have a canonical/supported way to script an action when Synchronet shuts down.
    - It would be nice to see some design consolidation of scripting triggers, as having to dig through module selections, fixed events, on-init-via-timed-menu events, event-triggered external programs, modopts.ini script hooks, etc. to find the best way to do something makes for a steep learning curve - especially when the answer is different depending on what you're trying to accomplish.


    well i'm not sure if your needs are something the rest of the community needs. luckily synchronet is open source and has scripting options. if you have the creativity to think up something, you can pull it off. i've done it. sometimes it's an ugly hack but it looks good to the user.

    if you dont have the programming ability you could always talk to someone and tip them for their hard work.
    ---
    þ Synchronet þ ::: BBSES.info - free BBS services :::
  • From Digital Man@VERT to Hunter-Z on Sun Oct 24 16:07:27 2021
    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
  • From DaiTengu@VERT/ENSEMBLE to Hunter-Z on Mon Nov 1 10:53:42 2021
    Re: Discord webook integration
    By: Hunter-Z to All on Sat Oct 23 2021 07:27 pm

    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.

    Hey, so a couple years ago I expanded upon echicken's twitter.js library, and created a script to post to Twitter any time someone logged on, logged off, posted a message or ran a door game. (I also believe there's an option to tweet if someone uploads/downloads a file, but I don't think it works correctly).

    https://github.com/DaiTengu/tweeter


    That might be a good starting point, at least for the hooks you want.

    DaiTengu

    ... In the future, everyone will be famous for fifteen minutes.

    ---
    þ Synchronet þ War Ensemble BBS - The sport is war, total war - warensemble.com