Skip to content

Instantly share code, notes, and snippets.

@rystaf
Last active December 7, 2021 08:58
Show Gist options
  • Save rystaf/98d49765e3d391a6f073a50e0bcaa6c0 to your computer and use it in GitHub Desktop.
Save rystaf/98d49765e3d391a6f073a50e0bcaa6c0 to your computer and use it in GitHub Desktop.
Gotify notifications for Windows 10 using BurntToast https://github.com/Windos/BurntToast
param ($domain="p.domain.com", $token="AAAAAAAA")
wscat -c "wss://$domain/stream?token=$token" | %{ convertfrom-json $_ } | where-object {$_.message.length -gt 0} |
%{
$appid = $_.appid
$icon = iwr https://$domain/application?token=$token |
%{ (convertfrom-json $_.content) } | where-object {$_.id -eq $appid} | select -expandproperty image
new-burnttoastnotification -applogo https://$domain/$icon -Text $_.title, $_.message
}
@rystaf
Copy link
Author

rystaf commented Aug 14, 2020

You can add this script as a scheduled task that runs at logon (check "Run whether user is logged in or not to hide window") and the action starts powershell.exe with the following arguments -file C:\path\to\gotify.ps1 -domain p.domain.com -token AAAAAAAAA

@poblabs
Copy link

poblabs commented Sep 9, 2020

I'm having an issue getting wscat working on Windows. It only works in the node terminal (I'm a bit of a node noob). Is there a way to connect to the websocket using pure powershell instead of the node app?

Edit: Ah, I needed to reboot. Duh it's windows you always have to reboot. Still would like to see if there's a way for pure powershell?

@12nick12
Copy link

12nick12 commented Oct 5, 2021

Not sure if you figured it out, but to use it without node you can use websocat which can be downloaded HERE instead of wscat.

Here's is my working example. I also added -UseBasicParsing

param ($domain="p.domain.com", $token="AAAAAAAA")
C:\Users\user\Downloads\websocat_win64.exe "wss://$domain/stream?token=$token" | %{ convertfrom-json $_ } | where-object {$_.message.length -gt 0} |
 %{ 
    $appid = $_.appid
    $icon = iwr https://$domain/application?token=$token -UseBasicParsing|
        %{ (convertfrom-json $_.content) } | where-object {$_.id -eq $appid} | select -expandproperty image
    new-burnttoastnotification -applogo https://$domain/$icon -Text $_.title, $_.message
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment