Compare commits
No commits in common. "e94fc2d4d32576ff521b68363368a528724f66d8" and "b3ab94ef7867f559d7ab5429ec84bf8b7b971a05" have entirely different histories.
e94fc2d4d3
...
b3ab94ef78
|
@ -7,6 +7,10 @@ WORKDIR /usr/src/app
|
||||||
COPY requirements.txt ./
|
COPY requirements.txt ./
|
||||||
RUN pip install --no-cache-dir -r 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 src/ ./src/
|
||||||
COPY main.py ./
|
COPY main.py ./
|
||||||
|
|
||||||
|
|
|
@ -38,6 +38,4 @@ services:
|
||||||
- <your whitelist>:/usr/src/app/whitelist.json
|
- <your whitelist>:/usr/src/app/whitelist.json
|
||||||
- <your world folder>:/usr/src/app/world
|
- <your world folder>:/usr/src/app/world
|
||||||
- <your server jar file>:/usr/src/app/server.jar
|
- <your server jar file>:/usr/src/app/server.jar
|
||||||
ports:
|
|
||||||
- 25565:25565
|
|
||||||
```
|
```
|
|
@ -39,11 +39,11 @@ matrix:
|
||||||
# When multiple RegEx strings apply, all are included.
|
# When multiple RegEx strings apply, all are included.
|
||||||
alternative_platforms:
|
alternative_platforms:
|
||||||
Discord:
|
Discord:
|
||||||
match: "@_?discord_\\d+:.+"
|
match: "@_?discord_\d+:.+"
|
||||||
text: D
|
text: D
|
||||||
color: aqua
|
color: aqua
|
||||||
WhatsApp:
|
WhatsApp:
|
||||||
match: "@whatsapp_\\d+:.+"
|
match: "@whatsapp_\d+:.+"
|
||||||
text: W
|
text: W
|
||||||
color: green
|
color: green
|
||||||
|
|
||||||
|
|
|
@ -6,7 +6,7 @@ from typing import Any, List, Optional
|
||||||
import yaml
|
import yaml
|
||||||
|
|
||||||
with open('config.yaml', 'r') as open_file:
|
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]:
|
def at(keys : List[str]) -> Optional[Any]:
|
||||||
"""
|
"""
|
||||||
|
|
|
@ -10,7 +10,7 @@ from typing import Union
|
||||||
import asyncio
|
import asyncio
|
||||||
import json
|
import json
|
||||||
import re
|
import re
|
||||||
from src.nbsr import NonBlockingStreamReader as NBSR, ProcessHasTerminated
|
from src.nbsr import NonBlockingStreamReader as NBSR
|
||||||
import src.config as config
|
import src.config as config
|
||||||
import src.build_server as build
|
import src.build_server as build
|
||||||
|
|
||||||
|
@ -23,24 +23,15 @@ p = Popen(config.RUN_COMMAND,
|
||||||
stdin = PIPE, stdout = PIPE, stderr = PIPE, shell = False)
|
stdin = PIPE, stdout = PIPE, stderr = PIPE, shell = False)
|
||||||
# wrap p.stdout with a NonBlockingStreamReader object:
|
# wrap p.stdout with a NonBlockingStreamReader object:
|
||||||
nbsr = NBSR(p.stdout)
|
nbsr = NBSR(p.stdout)
|
||||||
err_nbsr = NBSR(p.stderr)
|
|
||||||
|
|
||||||
async def start(client, mc_channel):
|
async def start(client, mc_channel):
|
||||||
"""
|
"""
|
||||||
Start reading from the Minecraft subprocess.
|
Start reading from the Minecraft subprocess.
|
||||||
"""
|
"""
|
||||||
# Provide 3 seconds to prepare the server
|
|
||||||
await asyncio.sleep(3)
|
await asyncio.sleep(3)
|
||||||
|
|
||||||
while True:
|
while True:
|
||||||
try:
|
|
||||||
output = nbsr.readline(0.1)
|
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
|
# 0.1 secs to let the shell output the result
|
||||||
if not output:
|
if not output:
|
||||||
await asyncio.sleep(1)
|
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\"",
|
r"\[[\d:]+\] \[Server thread\/INFO\]: Done \(\d+.?\d*s\)! For help, type \"help\"",
|
||||||
sentence):
|
sentence):
|
||||||
server_live = True
|
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(
|
if re.fullmatch(
|
||||||
r"\[[\d:]+\] \[Server thread\/INFO\]: Stopping server",
|
r"\[[\d:]+\] \[Server thread\/INFO\]: Stopping server",
|
||||||
|
|
|
@ -46,11 +46,6 @@ class NonBlockingStreamReader:
|
||||||
return self._q.get(block = timeout is not None,
|
return self._q.get(block = timeout is not None,
|
||||||
timeout = timeout)
|
timeout = timeout)
|
||||||
except Empty:
|
except Empty:
|
||||||
if self._t.is_alive():
|
|
||||||
return None
|
return None
|
||||||
else:
|
|
||||||
raise ProcessHasTerminated
|
|
||||||
|
|
||||||
class UnexpectedEndOfStream(Exception): pass
|
class UnexpectedEndOfStream(Exception): pass
|
||||||
|
|
||||||
class ProcessHasTerminated(Exception): pass
|
|
||||||
|
|
|
@ -1 +0,0 @@
|
||||||
[]
|
|
Loading…
Reference in New Issue