Last active
August 29, 2015 14:11
-
-
Save nolageek/2129089905cc0cd4092b to your computer and use it in GitHub Desktop.
Pushover Notifications v0.13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
load("http.js"); //this loads the http libraries which you will need to make requests to the web server | |
load("sbbsdefs.js"); | |
// Pushover notifications for synchronet v0.13 by nolageek | |
// | |
// This script adds simple push notifications to your synchronet bbs, using the pushover API, | |
// NOTE: install the free Pushover browser plugins or paid iOS or Android apps, you'll receive | |
// notifications for different events as soon as they occur on your BBS. Any configurable event | |
// can have a notification easily added, basically by running the script and adding a "KEYWORD" | |
// afterwards. | |
// | |
//// INSTRUCTIONS / INSTALLATION | |
// | |
// Upload script to a directory of your choice and add to BBS external programs. Be sure to | |
// select something as the Execute on Event. Command line is in the format ?pushover KEYWORD | |
// | |
// Example: | |
// Name: "Pushover Logon" | |
// Start Directory: ../xtrn/pushover | |
// Command Line: ?pushover.js logon | |
// Execute on Event: Logon, Only | |
// Do the same for other events: logon, logoff, newuser, sysopchat | |
// "keyword" can be anything after the script name in the "Command Line" and is only | |
// used as an identifier in the notification message so you'll know what event was triggered. | |
// | |
// They can be anything (just not blank) since it's the "Execute on event" setting that | |
// triggers the event itself. | |
// PUSHOVER CONFIGURATION: You'll need to create an app within the Pushover website and | |
// supply your AppToken and your UserKey. This lets Pushover know who is sending the message | |
// and who to send it to: | |
var poAppToken = "xxx"; | |
var poUserKey = "xxx"; // Who gets the message? | |
// | |
// Ignore these user names: use form ['username'] or ['username1','username2']; | |
var ignoreUser = []; | |
// | |
//// END CONFIGURATION //////////////////////// | |
// get command from commandline argument. ex "?pushover.js command" | |
var command = argv[0]; | |
// if command is omitted, let sysop know via notification. | |
if (command == null) { | |
var message = "No command specified."; | |
} else { | |
// otherwise create notification in form of "COMMAND: username(#0) from IP_ADDR" | |
var message = command.toUpperCase() + ": " + user.alias + "(#" + user.number + ") from " + user.ip_address; | |
} | |
// the actual function | |
function Pushover() { | |
// Set up the POST data for pushover | |
var postdata = "token=" + poAppToken | |
+ "&user=" + poUserKey | |
+ "&message=" + message; | |
// Send notification if user is NOT found in the ignore list | |
if (ignoreUser.indexOf(user.alias) < 0) { | |
this.request = new HTTPRequest(); | |
this.RequestURL = new URL("http://api.pushover.net/1/messages.json"); | |
var currentEndpoint = this.RequestURL.url; | |
response = this.request.Post(currentEndpoint,postdata); | |
} | |
} | |
Pushover(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment