Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
MINECRAFT_SERVER_IP=
MINECRAFT_SERVER_RCON_PORT=
MINECRAFT_SERVER_QUERY_PORT=
56 changes: 49 additions & 7 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
@@ -1,24 +1,66 @@
name: PR
on:
pull_request:
types: [opened]
types: [opened, synchronize]

jobs:
build:
runs-on: ubuntu-latest
outputs:
pylint-result: ${{ steps.pylint.outputs.result }}
steps:
- uses: actions/checkout@v4

- name: Setup python env
uses: actions/setup-python@v4
with:
python-version: '3.11'

- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install pylint
pip install -r requirements.txt

- name: Run pylint
id: pylint
run: |
set +e
OUTPUT=$(pylint $(git ls-files '*.py') 2>&1)
EXIT_CODE=$?
set -e

echo "Pylint Output"
echo "$OUTPUT"

echo "result<<EOF" >> $GITHUB_OUTPUT
if [ -z "$OUTPUT" ] || [ $EXIT_CODE -eq 0 ]; then
echo "No errors found" >> $GITHUB_OUTPUT
else
echo "$OUTPUT" | tail -20 >> $GITHUB_OUTPUT
fi
echo "EOF" >> $GITHUB_OUTPUT

exit $EXIT_CODE

SendDiscordWebhook:
runs-on: ubuntu-latest
needs: build
if: always()
steps:
- name: Discord notification
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK_URL }}
uses: Ilshidur/action-discord@master
with:
args: |
**RCON PR**
**PR** - **${{ github.event.pull_request.title }}**
${{ github.actor }} has raised a pull request!

**${{ github.event.pull_request.title }}**
${{ github.event.pull_request.body }}


Pylint result:
```
${{ needs.build.outputs.pylint-result }}
```
${{ github.event.pull_request.html_url }}

<@987695835678662666>
20 changes: 20 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
# IDE/Env related
.idea/
.venv/
venv/

.DS_Store
.env

# Flask related
*.pyc
__pycache__/

instance/

.pytest_cache/
.coverage
htmlcov/

# Later stuff
terraria.md
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,22 @@
# RCON
A remote console flask web-app for minecraft servers

### Development
To run the development server enter `flask --app hello run` from the project root after installing all dependencies in `requirements.txt` by using `pip install -r requirements.txt`

When developing on this repo you'll need to create a `.env` file, there's a `.env.example` file that should look something like this:
```
MINECRAFT_SERVER_IP=
MINECRAFT_SERVER_RCON_PORT=
MINECRAFT_SERVER_QUERY_PORT=
```

Mine (when populated) looks like this:
```
MINECRAFT_SERVER_IP=10.0.0.150
MINECRAFT_SERVER_RCON_PORT=25566
MINECRAFT_SERVER_QUERY_PORT=25567
```
When setting these it's important to know the RCON AND QUERY ports of your minecraft server, and *not* the general access port for the server. By default minecraft (java edition), uses port 25565 for the game, so if you're using that, you've got the wrong port. You can find the rcon and query ports in the `server.properties` file under `rcon.port` and `query.port` variables.

To use the file simply copy the `.env.example` and rename it as `.env` and populate it with your server's details.
22 changes: 22 additions & 0 deletions app/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
"""
https://flask.palletsprojects.com/en/stable/patterns/appfactories/
https://www.geeksforgeeks.org/python/__init__-in-python/
https://medium.com/@ferrohardian/application-factory-pattern-starting-your-flask-project-
"""
# This __init__ file is an application factory

import os
from flask import Flask
from flask.cli import load_dotenv

def create_app():
"""
Main create app function, used as a constructor
"""
app = Flask(__name__)
load_dotenv(".env")

from . import routes # pylint: disable=import-outside-toplevel
app.register_blueprint(routes.bp)

return app
16 changes: 16 additions & 0 deletions app/routes.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
"""
References:
https://flask.palletsprojects.com/en/stable/tutorial/views/
https://www.geeksforgeeks.org/python/flask-blueprints/
"""

from flask import Blueprint

bp = Blueprint('blueprint', __name__)

@bp.route('/hello')
def hello():
"""
First route as a guideline
"""
return "Hello world"
4 changes: 4 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
flask
flask-socketio
python-dotenv
pylint
Loading