-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
新增: .github/workflows/build.yml 修改: config.ini 修改: doc/introduction.md 新增: matrix_sync/commands.py 修改: matrix_sync/entry.py 新增: matrix_sync/globals.py 新增: matrix_sync/sync/__init__.py 移动: matrix_sync/receiver.py -> matrix_sync/sync/receiver.py 移动: matrix_sync/reporter.py -> matrix_sync/sync/reporter.py 修改: mcdreforged.plugin.json 修改: requirements.txt
- Loading branch information
1 parent
b686182
commit c64fc81
Showing
11 changed files
with
141 additions
and
86 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
name: 自动打包插件 | ||
|
||
on: | ||
push: | ||
branches: | ||
- main # 触发打包的分支,可以根据需要修改 | ||
pull_request: | ||
branches: | ||
- main # 可以修改为触发的 PR 分支 | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest # 运行环境 | ||
|
||
steps: | ||
- name: Checkout 代码 | ||
uses: actions/checkout@v3 | ||
|
||
- name: 设置 Python 环境 | ||
uses: actions/setup-python@v4 | ||
with: | ||
python-version: '3.12' # 设置 Python 版本 | ||
|
||
- name: 安装依赖 | ||
run: | | ||
python -m pip install --upgrade pip | ||
pip install -r requirements.txt # 安装依赖 | ||
- name: 打包插件 | ||
run: | | ||
bash pack_plugin.sh | ||
- name: 上传插件 | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: plugin | ||
path: /*.mcdr # 上传 .mcdr 文件 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,6 +3,6 @@ | |
[framework] | ||
ver=1 | ||
[main] | ||
ver=2.3.1 | ||
ver=2.4.0 | ||
[release] | ||
test=1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,3 @@ | ||
A MCDR (full name "MCDReforged") plugin sync messages between online game and Matrix groups. | ||
|
||
Version 2.2.0 fixes many long-pending issues and officially uses the Apache-2.0 open source license from that release. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import asyncio | ||
import json | ||
import matrix_sync.config | ||
|
||
from mcdreforged.api.all import * | ||
from matrix_sync.globals import * | ||
from matrix_sync.token import get_tip_read | ||
from matrix_sync.sync.receiver import getMsg | ||
|
||
psi = ServerInterface.psi() | ||
|
||
# Help tips. | ||
def help() -> RTextList: | ||
return RTextList( | ||
psi.rtr("matrix_sync.help_tips.title") + "\n", | ||
psi.rtr("matrix_sync.help_tips.start_command") + "\n", | ||
psi.rtr("matrix_sync.help_tips.stop_command") + "\n", | ||
psi.rtr("matrix_sync.help_tips.closetip_command") + "\n" | ||
) | ||
|
||
# Manually run sync processes. | ||
def manualSync(): | ||
if not tLock.locked(): | ||
start_room_msg() | ||
psi.say(psi.rtr("matrix_sync.manual_sync.start_tip")) | ||
read = asyncio.run(get_tip_read()) | ||
if not read: | ||
return RTextList( | ||
psi.rtr("matrix_sync.manual_sync.start_sync") + "\n", | ||
psi.rtr("matrix_sync.old_msg_sync") + "\n", | ||
psi.rtr("matrix_sync.old_msg_sync2") + "\n", | ||
psi.rtr("matrix_sync.old_msg_sync3") + "\n", | ||
psi.rtr("matrix_sync.old_msg_sync4") + "\n", | ||
psi.rtr("matrix_sync.old_msg_sync5") + "\n" | ||
) | ||
else: | ||
return psi.rtr("matrix_sync.manual_sync.start_sync") | ||
else: | ||
return psi.rtr("matrix_sync.manual_sync.start_error") | ||
|
||
# Manually stop sync processes. | ||
def stopSync(src): | ||
global sync_task | ||
if src.is_console: | ||
try: | ||
if sync_task is not None: | ||
sync_task.cancel() | ||
return psi.rtr("matrix_sync.manual_sync.stop_sync") | ||
else: | ||
return psi.rtr("matrix_sync.manual_sync.not_running") | ||
except Exception: | ||
return psi.rtr("matrix_sync.manual_sync.stop_error") | ||
else: | ||
return psi.rtr("matrix_sync.manual_sync.stop_denied") | ||
|
||
def closeTip(): | ||
TOKEN_FILE = matrix_sync.config.TOKEN_FILE | ||
with open(TOKEN_FILE, "r") as f: | ||
existing_data = json.load(f) | ||
existing_data["tip_read"] = True | ||
with open(TOKEN_FILE, "w") as f: | ||
json.dump(existing_data, f) | ||
return psi.rtr("matrix_sync.on_tip_read") | ||
|
||
# Sub thread to receive room messages from matrix without block main MCDR thread. | ||
@new_thread('MatrixReceiver') | ||
def start_room_msg(): | ||
with tLock: | ||
asyncio.run(on_room_msg()) | ||
|
||
async def on_room_msg(): | ||
global sync_task | ||
if sync_task is not None and not sync_task.done(): | ||
sync_task.cancel() | ||
await sync_task | ||
sync_task = asyncio.create_task(getMsg()) | ||
await sync_task |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import threading | ||
import matrix_sync.config | ||
|
||
from mcdreforged.api.all import * | ||
|
||
psi = ServerInterface.psi() | ||
tLock = threading.Lock() | ||
lock_is_None = matrix_sync.config.lock_is_None | ||
cleaned = False | ||
sync_task = None |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
from . import receiver | ||
from . import reporter |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
matrix-nio | ||
aiofiles | ||
asyncio | ||
mcdreforged |