Skip to content

Commit

Permalink
子包源代码更新及自动打包优化
Browse files Browse the repository at this point in the history
  • Loading branch information
Mooling0602 committed Nov 9, 2024
1 parent 8dcee58 commit 7d98cd4
Show file tree
Hide file tree
Showing 11 changed files with 54 additions and 23 deletions.
2 changes: 2 additions & 0 deletions config.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ ver=3
ver=2.4.0
[release]
test=1
[ci]
build=0
13 changes: 8 additions & 5 deletions pack_plugin.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ config_file="config.ini"
framework_ver=$(package_config "$config_file" "framework" "ver")
main_ver=$(package_config "$config_file" "main" "ver")
is_stable=$(package_config "$config_file" "release" "test")
build_plg=$(package_config "$config_file" "ci" "build")

if [ "$is_stable" -eq 1 ]; then
zip -r "MatrixSync-v${main_ver}-${framework_ver}.mcdr" mcdreforged.plugin.json requirements.txt LICENSE lang matrix_sync
else
zip -r "MatrixSync-v${main_ver}.mcdr" README.md README_en_us.md mcdreforged.plugin.json requirements.txt LICENSE lang matrix_sync
fi
if ["$build_plg" -eq 1]; then
if [ "$is_stable" -eq 1 ]; then
zip -r "MatrixSync-v${main_ver}-${framework_ver}.mcdr" mcdreforged.plugin.json requirements.txt LICENSE lang matrix_sync
else
zip -r "MatrixSync-v${main_ver}.mcdr" README.md README_en_us.md mcdreforged.plugin.json requirements.txt LICENSE lang matrix_sync
fi
fi
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

from mcdreforged.api.all import *
from matrix_sync.reporter import sendMsg
from atl_api import parseKey, parseValue, parseContent
from gtl_api import parseKey, parseValue, parseContent

psi = ServerInterface.psi()

Expand Down
2 changes: 1 addition & 1 deletion subpacks(rolling)/DeathTips/death_tips/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import matrix_sync.client

from mcdreforged.api.all import *
from atl_api import parseKey, parseValue
from gtl_api import parseKey, parseValue
from matrix_sync.reporter import sendMsg

psi = ServerInterface.psi()
Expand Down
2 changes: 1 addition & 1 deletion subpacks(rolling)/[MSync]AutoReply/mcdreforged.plugin.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "msync_auto_reply",
"version": "0.0.1",
"version": "0.0.2",
"name": "[MSync]AutoReply",
"description": {
"en_us": "A subpack of MatrixSync, automatically reply messages from room.",
Expand Down
42 changes: 34 additions & 8 deletions subpacks(rolling)/[MSync]AutoReply/msync_auto_reply/__init__.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,44 @@
import os
import matrix_sync.config
import matrix_sync.client

import yaml
from mcdreforged.api.all import *
from matrix_sync.reporter import sender
from matrix_sync.reporter import send_matrix

CONFIG_PATH = 'config/matrix_sync/auto_reply/config.yml'

DEFAULT_CONFIG = {
"triggers": {
"触发词1": "回复内容1",
"触发词2": "回复内容2",
"触发词3": "回复内容3"
}
}

def load_config():
if not os.path.exists(CONFIG_PATH):
os.makedirs(os.path.dirname(CONFIG_PATH), exist_ok=True)
with open(CONFIG_PATH, 'w', encoding='utf-8') as config_file:
yaml.dump(DEFAULT_CONFIG, config_file, allow_unicode=True)
with open(CONFIG_PATH, 'r', encoding='utf-8') as config_file:
return yaml.safe_load(config_file)

def on_load(server: PluginServerInterface, old):
global plugin_config
plugin_config = load_config()

server.logger.info("[MSync]AutoReply loaded.")
server.register_event_listener('MatrixRoomMessage', main)

def main(server: PluginServerInterface, message: str, sender: str):
user_id = matrix_sync.config.user_id
if not sender == user_id:
if message == "服务器连接信息":
clientStatus = matrix_sync.client.clientStatus
if clientStatus:
sender("服务器名称:星块服务器\n地址:play.staringplanet.top\n* 已进行SRV解析,Java版无需添加端口\n端口:21152")
server.logger.info("解析到指定内容,已自动发送回复")
triggers = plugin_config.get("triggers", {})

if sender != user_id:
for trigger_word, reply_content in triggers.items():
if message == trigger_word:
clientStatus = matrix_sync.client.clientStatus
if clientStatus:
send_matrix(reply_content)
server.logger.info("解析到指定内容,已自动发送回复")
break
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"id": "msync_more_msg",
"version": "0.0.1",
"version": "0.0.2",
"name": "[MSync]MoreMessages",
"description": {
"en_us": "A subpack of MatrixSync, transfer more kinds of messages from the game.",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import re

from matrix_sync.reporter import sender
from matrix_sync.reporter import send_matrix
from mcdreforged.api.all import *

psi = ServerInterface.psi()
Expand All @@ -11,7 +11,7 @@ def on_load(server: PluginServerInterface, old):
def on_user_info(server: PluginServerInterface, info: Info):
formatter(info)
if gameMsg is not None:
sender(gameMsg)
send_matrix(gameMsg)


def formatter(info: Info):
Expand Down
Binary file not shown.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import matrix_sync.client
import re
from matrix_sync.reporter import sender
from matrix_sync.reporter import send_matrix
from mcdreforged.api.all import *

def on_load(server: PluginServerInterface, old):
Expand All @@ -9,12 +9,12 @@ def on_load(server: PluginServerInterface, old):
def on_player_joined(server: PluginServerInterface, player: str, info: Info):
tip = f"[+]{player}"
if matrix_sync.client.clientStatus:
sender(tip)
send_matrix(tip)

def on_player_left(server: PluginServerInterface, player: str):
tip = f"[-]{player}"
if matrix_sync.client.clientStatus:
sender(tip)
send_matrix(tip)

def on_info(server: PluginServerInterface, info: Info):
if info.is_from_server and re.fullmatch(r'(.+) issued server command: (.+)', info.content):
Expand All @@ -25,4 +25,4 @@ def on_info(server: PluginServerInterface, info: Info):
server.say(f"* {player} 执行游戏指令 -> {command}")
clientStatus = matrix_sync.client.clientStatus
if clientStatus:
sender(f"* {player} 执行游戏指令 -> {command}")
send_matrix(f"* {player} 执行游戏指令 -> {command}")

0 comments on commit 7d98cd4

Please sign in to comment.