This bot fetches the current Ngrok TCP address for a Minecraft server and sends it to a designated Discord channel every morning.
- Retrieves the Ngrok public URL for a Minecraft server using the Ngrok API.
- Sends the address to a Discord channel through a bot.
- Automatically runs on startup and every hour, sending the IP address only if it changes.
- Spam reduction with a persistent cache
- Runs in a Docker container as an option
You can run this bot with Docker and provide configuration via a config.yaml file mounted as a volume:
- Create a
config.yamlfile with the following structure:
ngrok_api_token: "your_ngrok_api_token"
discord_bot_token: "your_discord_bot_token"
discord_channel_id: your_discord_channel_id # numeric, no quotesPull the image from GitHub Container Registry:
docker pull ghcr.io/michalovsky2112/minecraftserverngrokippuller:latestRun the container mounting your config file:
docker run -d \
--name msnipp-bot \
-v /path/to/your/config.yaml:/app/config.yaml:ro \
ghcr.io/michalovsky2112/minecraftserverngrokippuller:latestReplace /path/to/your/config.yaml with the full path to your config file on the host.
(Optional) To keep the container running after reboot:
docker update --restart unless-stopped msnipp-botBefore running this bot, you need to set up the following:
- Python 3.x: Ensure you have Python 3 installed.
- Ngrok Account: You will need an Ngrok account and an API token. You can get one by signing up at Ngrok.
- Discord Account: You will need to create a Discord bot and get a token from the Discord Developer Portal.
-
Clone this repository:
git clone https://github.com/Michalovsky2112/MinecraftServerNgrokIPPuller.git cd MinecraftServerNgrokIPPuller -
Create and activate a virtual environment:
python3 -m venv MSNIPP source MSNIPP/bin/activate # For Linux/macOS MSNIPP\Scripts\activate # For Windows
-
Install the required dependencies:
pip install -r requirements.txt
-
Create a
config.yamlfile to store your sensitive information:NGROK_API_TOKEN: 'your_ngrok_api_token' TOKEN: 'your_discord_bot_token' CHANNEL_ID: 'your_discord_channel_id'
Replace the placeholders with your actual values.
-
Run the bot:
python bot.py
The bot will now send the Minecraft server's Ngrok address to the specified Discord channel at startup.
If you run linux, you can run the bot in a screen - if installed.
screen -dmS bot ./MSNIPP/bin/python3 bot.pyThis will run the bot in a detached screen. To access it, execute: screen -r bot. To exit while leaving running in background, press Ctrl + A and then Ctrl + D.
If you want to contribute to this project, feel free to fork the repository, create a new branch, and submit a pull request with your changes. All contributions are welcome!
This project is licensed under the GNU General Public License v3.0 - see the LICENSE file for details.