/mcs_notify

Bash-based notification system for minecraft servers

Primary LanguageShell

mcs_notify: A notification system for Minecraft Servers

Background

This repository provides a collection of three bash scripts that hack together notifications on the minecraft server log file (latest.log) to the Maker channel of ifthisthenthat (IFTTT) so that players can receive notifications (on a mobile device, or via SMS, for example) about events on the server. Currently only supports events related to players logging on or off of a server.

The scripts run under bash on *-nix systems, and have been tested on Ubuntu Linux 14.04.

Requirements

  • a minecraft server running locally
  • an OS with ability to parse bash scripts
  • curl, a library for posting web requests; on ubuntu, install using sudo apt-get install curl
  • for any users wishing to receive notifications:

How it works

The main script exec_when_changed.sh monitors the activity of a server log. The minecraft server logs events as they happen to the file [your_server_directory]/logs/latest.log. When the exec_when_changed.sh script detects changes, it pipes the latest output into process_output.sh, which parses the text for particular events. When a desired event is detected (e.g., player logs in), it pipes the message text to the notify.sh script, which POSTS a web request to IFTTT. Currently, notify.sh only watches for player login/logout events, but you can modify the notify.sh script to watch for other types of events.

You will need to create a custom player_keys file and save it in the directory with the other mcs_notify files. When the notify.sh script is triggered, it reads in data from player_keys to determine the web requests that needs to be sent. Each person who wishes to receive notifications about server events needs to have a separate line in this file. Each line is of the format:

[minecraft_in_game_user_name] [IFTTT secret key]

So, for example, the player named Herobrine_XXX with IFTTT key 3xjjf318-D1ffo would appear in the file as:

Herobrine_XXX 3xjjf318-D1ffo

Any player wishing to set up notifications through IFTTT will need to create a Maker Trigger Channel to receive the web event player_login. The message is passed through {{Value 1}} of the JSON payload.

A logical place to put the mcs_notify directory is as a sub-directory of your minecraft server directory. Then, after starting up a server instance, invoke the following command to start monitoring the server log:

cd mcs_notify
./exec_when_changed.sh ../logs/latest.log