Refactored
This commit is contained in:
parent
e7248723f5
commit
715d0527bf
6 changed files with 327 additions and 106 deletions
42
main.py
42
main.py
|
|
@ -1,41 +1,17 @@
|
|||
import asyncio
|
||||
import os
|
||||
from importlib import import_module
|
||||
|
||||
from libminecraft import Minecraft
|
||||
from libsignal import Group, ReceivedMessage, Signal
|
||||
from libbot import minecraft, signal
|
||||
|
||||
RChat = Group("RS Chat", "5PlbXaPmWZQkhmuyyC/fkWTy8K+BqomjK7byVDyxmpo=")
|
||||
for module in os.listdir("modules"):
|
||||
if module.endswith(".py"):
|
||||
import_module("modules." + module.rstrip(".py"))
|
||||
|
||||
|
||||
async def main():
|
||||
minecraft = Minecraft("http://localhost", 42101, "1234")
|
||||
signal = Signal("http://localhost", 42069)
|
||||
|
||||
##########################
|
||||
# === RETARDS SERVER === #
|
||||
##########################
|
||||
|
||||
@signal.onMessage(RChat)
|
||||
async def onRChatMessage(message: ReceivedMessage):
|
||||
username = message.user.last_nickname or message.user.name
|
||||
msg = message.message.replace('"', '\\"')
|
||||
await minecraft.command(f'tellraw @a "<{username}> {msg}"')
|
||||
|
||||
@minecraft.onPlayerChat()
|
||||
async def onRServerMessage(player: str, message: str):
|
||||
await signal.sendMessage(f"<{player}> {message}", RChat)
|
||||
|
||||
##################
|
||||
# === GLOBAL === #
|
||||
##################
|
||||
|
||||
@signal.onMessage()
|
||||
async def onMessage(message: ReceivedMessage):
|
||||
if "clanker" in message.message.lower():
|
||||
await signal.sendMessage(
|
||||
"Don't use the c-word nigga", message.group or message.user
|
||||
)
|
||||
|
||||
await signal.loop()
|
||||
await asyncio.gather(minecraft.loop(), signal.loop())
|
||||
|
||||
|
||||
asyncio.run(main())
|
||||
if __name__ == "__main__":
|
||||
asyncio.run(main())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue