Compare commits

..

No commits in common. "e94fc2d4d32576ff521b68363368a528724f66d8" and "b3ab94ef7867f559d7ab5429ec84bf8b7b971a05" have entirely different histories.

7 changed files with 12 additions and 25 deletions

View File

@ -7,6 +7,10 @@ WORKDIR /usr/src/app
COPY requirements.txt ./
RUN pip install --no-cache-dir -r requirements.txt
# # Prepare MC server
# COPY server.jar ./
# RUN java -jar server.jar --nogui
COPY src/ ./src/
COPY main.py ./

View File

@ -38,6 +38,4 @@ services:
- <your whitelist>:/usr/src/app/whitelist.json
- <your world folder>:/usr/src/app/world
- <your server jar file>:/usr/src/app/server.jar
ports:
- 25565:25565
```

View File

@ -39,11 +39,11 @@ matrix:
# When multiple RegEx strings apply, all are included.
alternative_platforms:
Discord:
match: "@_?discord_\\d+:.+"
match: "@_?discord_\d+:.+"
text: D
color: aqua
WhatsApp:
match: "@whatsapp_\\d+:.+"
match: "@whatsapp_\d+:.+"
text: W
color: green

View File

@ -6,7 +6,7 @@ from typing import Any, List, Optional
import yaml
with open('config.yaml', 'r') as open_file:
SETTINGS = yaml.load(open_file, Loader=yaml.Loader)
SETTINGS = yaml.load(open_file)
def at(keys : List[str]) -> Optional[Any]:
"""

View File

@ -10,7 +10,7 @@ from typing import Union
import asyncio
import json
import re
from src.nbsr import NonBlockingStreamReader as NBSR, ProcessHasTerminated
from src.nbsr import NonBlockingStreamReader as NBSR
import src.config as config
import src.build_server as build
@ -23,24 +23,15 @@ p = Popen(config.RUN_COMMAND,
stdin = PIPE, stdout = PIPE, stderr = PIPE, shell = False)
# wrap p.stdout with a NonBlockingStreamReader object:
nbsr = NBSR(p.stdout)
err_nbsr = NBSR(p.stderr)
async def start(client, mc_channel):
"""
Start reading from the Minecraft subprocess.
"""
# Provide 3 seconds to prepare the server
await asyncio.sleep(3)
while True:
try:
output = nbsr.readline(0.1)
except ProcessHasTerminated:
print('==================================\nERROR LOGS :')
while True:
output = err_nbsr.readline(0.1)
print(output)
# 0.1 secs to let the shell output the result
if not output:
await asyncio.sleep(1)
@ -90,7 +81,7 @@ def process_message(sentence : str) -> Union[str, None]:
r"\[[\d:]+\] \[Server thread\/INFO\]: Done \(\d+.?\d*s\)! For help, type \"help\"",
sentence):
server_live = True
return f"The Minecraft server is live. The server is reachable at <code>{config.SERVER_IP}</code>.", f"The minecraft server is live. The server is reachable at <code>{config.SERVER_IP}</code>."
return f"The Minecraft server is live. The server is reacable at <code>{config.SERVER_IP}</code>.", f"The minecraft server is live. The server is reacable at <code>{config.SERVER_IP}</code>."
if re.fullmatch(
r"\[[\d:]+\] \[Server thread\/INFO\]: Stopping server",

View File

@ -46,11 +46,6 @@ class NonBlockingStreamReader:
return self._q.get(block = timeout is not None,
timeout = timeout)
except Empty:
if self._t.is_alive():
return None
else:
raise ProcessHasTerminated
class UnexpectedEndOfStream(Exception): pass
class ProcessHasTerminated(Exception): pass

View File

@ -1 +0,0 @@
[]