This bot provides the ability for Partymeister to broadcast certain events to several destinations, including public and/or internal IRC channels, Telegram channels, Slack, Discord, and push notifications to mobile apps via OneSignal. It exposes an HTTP endpoint that is called by Partymeister for every broadcast.
- Install node.js and npm.
- Install dependencies by changing to the
stuhljs
directory and runningnpm install
. - Copy
config.sample.json
toconfig.json
and adjust settings as needed. - Run
node stuhl.js
. - Configure the HTTP address and key in Partymeister.
Note: You can provide the name of an alternative configuration file as a command line parameter to load instead of config.json
.
The configuration file consists of plugins, channels, and destinations. Each plugin corresponds to one service the bot connects to, such as IRC or Slack. For each plugin any number of channels can be defined. The meaning of what a channel is varies depending on the plugin: For the IRC plugin, each channel corresponds to an IRC channel the bot should join. For the OneSignal plugin, each channel is a configurable segment of app users.
Destinations are logical groupings of channels. The idea here is to create one destination for each kind of message (such as general announcements, deadlines, orga internal information, etc.) and then map them to the channels that this specific kind of message should be sent to. That way the mapping can later be changed without having to reconfigure Partymeister.
See the sample file config.sample.json
for examples.
If the configuration option frontendEnabled
is set to true
, accessing the service from a (reasonably modern) web browser will show a simple frontend allowing you to send notifications.
Notifications are sent by posting a JSON object to /stuhl
containing the following properties:
key
: Needs to match the access key in the configuration filedestination
: Name of the destination this notification should be sent tomessage
: Notification contenttitle
: Optional heading of the notificationlink
: Optional link associated with the notificationlevel
: Optional message level (good
,bad
,boring
) that controls how the notification is displayed (not supported by all plugins)ttl
: Optional integer defining the time in seconds until this notification should be considered expired (currently only supported by OneSignal plugin)
The HTTP response is a JSON object that contains the boolean field success
and an error
string if applicable.
Each plugin is a file in the plugins
directory that exports a class supporting the following:
- Constructor: Gets the plugin's configuration file section as its single argument
start()
method: Causes the plugin to start running, establish network connections, etc.channels
property: Array of channel objects (see below)
Every channel object needs to have:
name
property: The channel name, as set in the configuration filebroadcast(message, title, link, level, ttl)
method: Broadcasts a message to this channel