-
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.
- Loading branch information
1 parent
8dcee58
commit 7d98cd4
Showing
11 changed files
with
54 additions
and
23 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 |
---|---|---|
|
@@ -6,3 +6,5 @@ ver=3 | |
ver=2.4.0 | ||
[release] | ||
test=1 | ||
[ci] | ||
build=0 |
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
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
42 changes: 34 additions & 8 deletions
42
subpacks(rolling)/[MSync]AutoReply/msync_auto_reply/__init__.py
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,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.
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
Binary file not shown.
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