This software has a lot of interconnected parts, so bear with me; this will take a bit more time to put together than the average Spigot plugin.
Turtleduck makes use of the Telegram Bot API. Use of the API is completely free, though you will have to register an account for your new bot.
- Obtain a Telegram Bot API token from the @BotFather account on Telegram. Instructions can be found here.
- Save the API token that the bot gives you. You'll need it later.
Turtleduck uses a 16-byte hexadecimal key to sign its internal requests. This ensures that outsiders cannot abuse Turtleduck to spam your Minecraft server chat or your registered Telegram chats.
- A Python script named
generate-hmac.py
is included in the base directory of this repo that will generate the key for you. Run it in your terminal to generate a key. (You will need Python 2 or 3 installed.) - Save the generated HMAC key for later.
- Extract the contents of the web-component directory to a publicly-accessible directory on your web server.
- Install Composer if you haven't already.
- Open a shell where you extracted the web-component directory.
- Run
composer install
to download the requisite dependencies.
-
Create a new database on your MySQL server, if you wish.
-
Import the
install.sql
file from the web-component directory into your MySQL database. -
To add allowed users, simply add new rows to the
turtleduck_allowed_users
table. The username column is the Telegram username you wish to allow, and you don't need to set anything in the date_added column (it will be updated automatically.)- You can execute this SQL query to add allowed users:
INSERT INTO turtleduck_allowed_users VALUES('MyUsername', NULL);
Just remember to replace MyUsername with the username you wish to allow.
- You can execute this SQL query to add allowed users:
- Open your Spigot server's
server.properties
file. - Enable RCON.
- Set
enable-rcon=true
. Add this to your config if it doesn't exist. - Set
rcon-password
to a long, random alphanumeric password. I recommend using a strong password generator for this. - Ensure that the
rcon.port
setting exists. Normally, this should be set to 25575.
- Set
- Save your
server.properties
config. - Install the Turtleduck plugin, and restart your Spigot server.
- A Turtleduck folder should have been generated in your server's plugins
directory. Open the
config.yml
file that's inside it. - Set the
hmacKey
variable to the HMAC signing key that you generated in Step 2. - Set the
postUrl
variable to the URL ofturtleduck/spigot-interface.php
on your web server. For example, if your domain is example.com and you extracted the web-component directory to the root of your web server's public directory, this would be:https://www.example.com/turtleduck/spigot-interface.php
- Save the
config.yml
file. - Restart your Spigot server again.
- Open the
config.php
file on your web server and set the following constants accordingly.- MC_SERVER_ADDR: The address of your Spigot server.
If your Spigot server is on the same machine as your web server, then
localhost
should suffice. - QUERY_PORT: The port that your Spigot server runs on. Usually, this
is 25565 unless you changed it in Spigot's
server.properties
. - RCON_PORT: The port that your Spigot server's RCON (remote console)
service runs on. Usually, this is 25575 unless you changed it in Spigot's
server.properties
. - RCON_PASSWORD: The RCON password that you set in Step 5.
- DB_HOSTNAME: The hostname of your MySQL server. If it's on the same
machine as your web server, then
localhost
should suffice. - DB_NAME: The name of the database you setup in Step 4.
- DB_PORT: The port that your MySQL server runs on. Usually 3306.
- DB_USER: The name of the MySQL user that this application will use.
- DB_PASS: The password of the MySQL user that this application will use.
- TURTLEDUCK_HMAC: The HMAC signing key that you generated in Step 2.
- TURTLEDUCK_TELEGRAM_TOKEN: The API token that you received in Step 1.
- MC_SERVER_ADDR: The address of your Spigot server.
If your Spigot server is on the same machine as your web server, then
- Save the
config.php
file.
TODO
- Start a conversation with your bot on Telegram. You can either initiate a regular chat with it, or add the bot and yourself to a new group.
- Send the
/register
command. If you are an allowed user, it should respond with "Registered successfully!"
Now that you've registered this chat, all messages sent with /sos on your Minecraft server will be forwarded to this chat. You can register up to five Telegram chats to receive messages. To reply to a message, use the "Reply To" action in Telegram.