Moved main.py to serve.py, implemented modularization and added control module
This commit is contained in:
parent
ad6190b46a
commit
e185786959
6 changed files with 138 additions and 21 deletions
47
modules/control.py
Normal file
47
modules/control.py
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
import libminecraft
|
||||
import libsignal
|
||||
import libcommon
|
||||
|
||||
RetardsServer = libcommon.Group(
|
||||
"Retards Server", "5PlbXaPmWZQkhmuyyC/fkWTy8K+BqomjK7byVDyxmpo=")
|
||||
|
||||
|
||||
@libsignal.onMessage(RetardsServer)
|
||||
def signalControl(usr: str, msg: str):
|
||||
if usr == "Malasaur" and msg.startswith("!"):
|
||||
match msg.split():
|
||||
case ["!modules", "list"]:
|
||||
available_modules, loaded_modules, unloaded_modules = libcommon.listModules()
|
||||
libsignal.sendMessage(
|
||||
f"""Available modules: {" ".join(available_modules)}
|
||||
Loaded modules: {" ".join(loaded_modules)}
|
||||
Unloaded modules: {" ".join(unloaded_modules)}""", RetardsServer
|
||||
)
|
||||
case ["!modules", "load", *modules]:
|
||||
for module in modules:
|
||||
try:
|
||||
libcommon.loadModule(module)
|
||||
libsignal.sendMessage(
|
||||
f"[Serve] '{module}' successfully loaded.", RetardsServer)
|
||||
except Exception as e:
|
||||
libsignal.sendMessage(
|
||||
f"[Serve] Error loading '{module}': {e}", RetardsServer)
|
||||
case ["!modules", "unload", *modules]:
|
||||
for module in modules:
|
||||
try:
|
||||
libcommon.unloadModule(module)
|
||||
libsignal.sendMessage(
|
||||
f"[Serve] '{module}' successfully unloaded.", RetardsServer)
|
||||
except Exception as e:
|
||||
libsignal.sendMessage(
|
||||
f"[Serve] Error unloading '{module}': {e}", RetardsServer)
|
||||
case ["!modules", "reload", *modules]:
|
||||
for module in modules:
|
||||
try:
|
||||
libcommon.unloadModule(module)
|
||||
libcommon.loadModule(module)
|
||||
libsignal.sendMessage(
|
||||
f"[Serve] '{module}' successfully reloaded.", RetardsServer)
|
||||
except Exception as e:
|
||||
libsignal.sendMessage(
|
||||
f"[Serve] Error reloading '{module}': {e}", RetardsServer)
|
||||
5
modules/shazam.py
Normal file
5
modules/shazam.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
|
||||
@libminecraft.onConsoleOutput(r"\[.*\] \[Server thread\/INFO\]: Set Malasaur's game mode to (.*) Mode")
|
||||
def malasaurSetGamemode(gamemode: str):
|
||||
global malasaurGamemode
|
||||
malasaurGamemode = gamemode.lower()
|
||||
Loading…
Add table
Add a link
Reference in a new issue