Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooling0602 authored May 24, 2024
1 parent 33c94fc commit ea5387d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion matrix_sync/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def on_server_startup(server: PluginServerInterface):
def on_user_info(server: PluginServerInterface, info: Info):
formater(server, info)
if matrix_sync.reporter.report:
asyncio.run(sendMsg())
asyncio.run(sendMsg(matrix_sync.reporter.gameMsg))

def on_server_stop(server: PluginServerInterface, server_return_code: int):
if server_return_code == 0:
Expand Down
12 changes: 6 additions & 6 deletions matrix_sync/reporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@
def formater(server: PluginServerInterface, info: Info):
# psi.logger.info(psi.rtr("matrix_sync.sync_tips.test"))
# Debug code: Uncomment the above to determine whether game messages have been started to be reported.
global message, report
global gameMsg, report
console_tr = psi.rtr("matrix_sync.tr.cs")
message = f"<{info.player}> {info.content}"
gameMsg = f"<{info.player}> {info.content}"
if info.player is None:
if re.fullmatch(r'say \S*', info.content):
msg_content = '{}'.format(info.content.rsplit(' ', 1)[1])
message = f"<{console_tr}> {msg_content}"
gameMsg = f"<{console_tr}> {msg_content}"
else:
option = psi.rtr("matrix_sync.on_console.commands")
message = f"<{console_tr}> {option} -> {info.content}"
gameMsg = f"<{console_tr}> {option} -> {info.content}"
if info.content == "stop":
message = psi.rtr("matrix_sync.sync_tips.server_stopping")
gameMsg = psi.rtr("matrix_sync.sync_tips.server_stopping")
report = False
if matrix_sync.client.clientStatus or os.path.exists(matrix_sync.entry.TOKEN_FILE):
report = True

# Game Message reporter.
async def sendMsg() -> None:
async def sendMsg(message) -> None:
async with aiofiles.open(matrix_sync.entry.TOKEN_FILE, "r") as f:
contents = await f.read()
cache = json.loads(contents)
Expand Down

0 comments on commit ea5387d

Please sign in to comment.