mioku-plugin-terraria 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +4 -8
- package/index.ts +6 -6
- package/package.json +6 -9
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# mioku-plugin-terraria
|
|
2
2
|
|
|
3
|
-
为 Mioku 提供 Terraria(TShock)服务器与 QQ 群消息互通能力,使用 [TianSuo](https://github.com/
|
|
3
|
+
为 Mioku 提供 Terraria(TShock)服务器与 QQ 群消息互通能力,使用 [TianSuo](https://github.com/Jerryplusy/TianSuo) 协议(JSON over WebSocket)。
|
|
4
4
|
|
|
5
5
|
## 功能特性
|
|
6
6
|
|
|
@@ -9,13 +9,9 @@
|
|
|
9
9
|
- **多服务器支持**:可同时连接多台 Terraria 服务器,每台独立配置
|
|
10
10
|
- **自动重连**:连接断开后按指数退避自动重连,可配置最大重试次数
|
|
11
11
|
|
|
12
|
-
##
|
|
12
|
+
## 服务端要求
|
|
13
13
|
|
|
14
|
-
Terraria 服务器需安装 [TianSuo](https://github.com/
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
bun install
|
|
18
|
-
```
|
|
14
|
+
Terraria 服务器需安装 [TianSuo](https://github.com/Jerryplusy/TianSuo) TShock 插件
|
|
19
15
|
|
|
20
16
|
## 配置
|
|
21
17
|
|
|
@@ -32,6 +28,6 @@ bun install
|
|
|
32
28
|
|
|
33
29
|
## 鸣谢
|
|
34
30
|
|
|
35
|
-
- [TianSuo](https://github.com/
|
|
31
|
+
- [TianSuo](https://github.com/Jerryplusy/TianSuo):Terraria WebSocket 桥
|
|
36
32
|
- [TShock](https://github.com/TShock/TShock) 与 [Pryaxis](https://github.com/Pryaxis):Terraria 服务端框架与插件 API
|
|
37
33
|
- [Re-Logic](https://www.terraria.org/):Terraria
|
package/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { definePlugin, getService, Services, type
|
|
1
|
+
import { definePlugin, getService, Services, type MiokuContext } from "mioku";
|
|
2
2
|
import { handleStatus } from "./handlers/status";
|
|
3
3
|
import { handleSync } from "./handlers/sync";
|
|
4
4
|
import { handleReconnect } from "./handlers/reconnect";
|
|
@@ -22,7 +22,7 @@ export default definePlugin({
|
|
|
22
22
|
version: "1.0.0",
|
|
23
23
|
description: "Terraria 服务器与 QQ 群消息互通插件,基于 TianSuo 协议",
|
|
24
24
|
|
|
25
|
-
async setup(ctx:
|
|
25
|
+
async setup(ctx: MiokuContext) {
|
|
26
26
|
const configService = getService(ctx, Services.Config);
|
|
27
27
|
|
|
28
28
|
const configHandler = createConfigHandler(configService);
|
|
@@ -112,7 +112,7 @@ export default definePlugin({
|
|
|
112
112
|
});
|
|
113
113
|
|
|
114
114
|
async function handleTerrariaEvent(
|
|
115
|
-
ctx:
|
|
115
|
+
ctx: MiokuContext,
|
|
116
116
|
raw: { serverName: string; name: string; data: Record<string, unknown> },
|
|
117
117
|
config: TerrariaConfig,
|
|
118
118
|
configHandler: ReturnType<typeof createConfigHandler>,
|
|
@@ -152,11 +152,11 @@ async function handleTerrariaEvent(
|
|
|
152
152
|
const groups = serverItem.group_list ? [serverItem.group_list] : [];
|
|
153
153
|
|
|
154
154
|
for (const botId of bots) {
|
|
155
|
-
const bot = ctx.pickBot(
|
|
155
|
+
const bot = ctx.pickBot(botId);
|
|
156
156
|
if (!bot) continue;
|
|
157
157
|
for (const groupId of groups) {
|
|
158
158
|
try {
|
|
159
|
-
await bot.
|
|
159
|
+
await bot.sendMessage({ type: "group", group_id: groupId}, messageText);
|
|
160
160
|
} catch (err) {
|
|
161
161
|
ctx.logger.error(
|
|
162
162
|
`[Terraria] 发送消息到群 ${groupId} 失败: ${err}`,
|
|
@@ -167,7 +167,7 @@ async function handleTerrariaEvent(
|
|
|
167
167
|
}
|
|
168
168
|
|
|
169
169
|
async function forwardToTerraria(
|
|
170
|
-
ctx:
|
|
170
|
+
ctx: MiokuContext,
|
|
171
171
|
event: any,
|
|
172
172
|
config: TerrariaConfig,
|
|
173
173
|
configHandler: ReturnType<typeof createConfigHandler>,
|
package/package.json
CHANGED
|
@@ -1,21 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "mioku-plugin-terraria",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0",
|
|
4
4
|
"description": "Terraria 服务器与 QQ 群消息互通插件,基于 TianSuo 协议",
|
|
5
5
|
"main": "index.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"keywords": [
|
|
8
|
-
"mioku"
|
|
9
|
-
"terraria",
|
|
10
|
-
"tshock",
|
|
11
|
-
"tiansuo"
|
|
8
|
+
"mioku"
|
|
12
9
|
],
|
|
13
10
|
"repository": {
|
|
14
11
|
"type": "git",
|
|
15
12
|
"url": "https://github.com/mioku-lab/mioku-plugin-terraria.git"
|
|
16
13
|
},
|
|
17
14
|
"mioku": {
|
|
18
|
-
"services": [
|
|
15
|
+
"services": [
|
|
16
|
+
"config"
|
|
17
|
+
],
|
|
19
18
|
"accessHooks": [
|
|
20
19
|
{
|
|
21
20
|
"id": "/ts 状态",
|
|
@@ -67,12 +66,10 @@
|
|
|
67
66
|
"ws": "^8.18.0"
|
|
68
67
|
},
|
|
69
68
|
"peerDependencies": {
|
|
70
|
-
"mioku": "^0.
|
|
71
|
-
"mioki": "^0.16.0"
|
|
69
|
+
"mioku": "^1.0.0"
|
|
72
70
|
},
|
|
73
71
|
"devDependencies": {
|
|
74
72
|
"mioku": "workspace:*",
|
|
75
|
-
"mioki": "^0.16.0",
|
|
76
73
|
"@types/ws": "^8.5.13"
|
|
77
74
|
}
|
|
78
75
|
}
|