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
82 changes: 82 additions & 0 deletions .github/workflows/update-main-conf.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Update main.conf

on:
pull_request:
types:
- closed
branches:
- main

permissions:
contents: write

jobs:
update-main-conf:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest

steps:
- name: Check out main
uses: actions/checkout@v4
with:
ref: main
fetch-depth: 0

- name: Generate main.conf
run: |
python <<'PY'
import re
from pathlib import Path

def read_setting(text, key):
match = re.search(rf'(?m)^{re.escape(key)}:\s*"(.*)"\s*$', text)
if not match:
raise SystemExit(f'Missing "{key}" in settings.yml')
return match.group(1)

def conf_quote(value):
return value.replace('\\', '\\\\').replace('"', '\\"')

settings = Path('settings.yml').read_text(encoding='utf-8')
title = read_setting(settings, 'title')
description_template = read_setting(settings, 'description')

messages = [
line.strip()
for line in Path('edit-me.txt').read_text(encoding='utf-8').splitlines()
if line.strip()
]

motds = ['motds=[']
for index, message in enumerate(messages):
description = description_template.replace('{motd}', message)
motds.extend([
' {',
f' line1="{conf_quote(title)}"',
f' line2="{conf_quote(description)}"',
' icon=random',
f' }}{"," if index < len(messages) - 1 else ""}',
])
motds.append(']')
motds_block = '\n'.join(motds)

config_path = Path('main.conf')
config = config_path.read_text(encoding='utf-8')
updated = re.sub(
r'(?s)motds=\[\s*.*?\n\]',
motds_block,
config,
count=1,
)
if updated == config:
print('main.conf is already up to date')
else:
config_path.write_text(updated, encoding='utf-8')
print('Updated main.conf')
PY

- name: Commit generated main.conf
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Update main.conf from edit-me.txt
file_pattern: main.conf
18 changes: 16 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
# MOTD

This is a collection of all messages that are displayed in the server list. The configuration file can be found in [main.conf](main.conf).
This is a collection of all messages that are displayed in the server list. The built configuration file can be found in [main.conf](main.conf).

![Server message of the day](images/motd.png)

## Pull requests

We accept your submissions! You may clone this repository, modify the `motds` array in [main.conf](main.conf) and create a pull request in <https://github.com/BorderMC/motd/pulls>.
We accept your submissions! You may clone this repository, add a new line in [edit-me.txt](edit-me.txt) and create a pull request in <https://github.com/BorderMC/motd/pulls>.

When the pull request gets approved, Github will update [main.conf](main.conf) to match [edit-me.txt](edit-me.txt).

### Rules

To avoid controversy or inappropriate sentences, the guideline rules below will define what we will **NOT** accept:

- No advertisements
- No slurs

## How to contribute

- Clone project using `git clone https://github.com/BorderMC/motd.git`
- Read [the rules](#rules)
- Edit [edit-me.txt](edit-me.txt)
- Make a branch with `git branch <yourusername>/<description>` for example `git branch pernio/nether-reset-info`
- Switch to branch with `git switch <yourusername>/<description>` for example `git switch pernio/nether-reset-info`
- Add all files to git using `git add .`
- Commit message using `git commit -m "<message>"` for example `git commit -m "Added new motd message"`
- Push using `git push --set-upstream origin <yourusername>/<description>` for example `git push --set-upstream origin pernio/nether-reset-info`
- Create a pull request in <https://github.com/BorderMC/motd/pulls>
3 changes: 3 additions & 0 deletions edit-me.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
We're fun to play with
Now fully open!
Nether reset 1/10/2026
8 changes: 3 additions & 5 deletions main.conf
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

# -----------------------------------------------

# Add a new item in motds.
# DO NOT EDIT THIS FILE

# -----------------------------------------------

motds=[
{
Expand All @@ -16,10 +18,6 @@ motds=[
}
]

# Do not edit below this line

# -----------------------------------------------

motd-enabled=true
icon-enabled=true

Expand Down
8 changes: 8 additions & 0 deletions settings.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# -----------------------------------------------

# DO NOT EDIT THIS FILE

# -----------------------------------------------

title: "<bold><red>BorderMC</red> <dark_gray>-</dark_gray> <gradient:#00B8D9:#00E5D4:#00B8D9>Released!</gradient></bold>"
description: "<gray>{motd}</gray>"
Loading