koishi-plugin-ll-brick 1.0.1 → 1.0.3
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/lib/index.js +15 -6
- package/package.json +2 -2
- package/readme.md +20 -0
package/lib/index.js
CHANGED
|
@@ -52,6 +52,14 @@ exports.Config = koishi_1.Schema.intersect([
|
|
|
52
52
|
])
|
|
53
53
|
]);
|
|
54
54
|
exports.inject = ["database"];
|
|
55
|
+
// 生成消息中的 @。QQ 官方机器人使用 <qqbot-at-user id="..." /> 新格式,
|
|
56
|
+
// 且需要 < > 转义以绕过 koishi 元素管线(否则未知标签会被丢弃);其他平台沿用 h.at。
|
|
57
|
+
function atUser(session, userId) {
|
|
58
|
+
if (session?.platform === 'qq') {
|
|
59
|
+
return `<qqbot-at-user id="${userId}" />`;
|
|
60
|
+
}
|
|
61
|
+
return koishi_1.h.at(userId).toString();
|
|
62
|
+
}
|
|
55
63
|
async function apply(ctx, config) {
|
|
56
64
|
ctx.model.extend('brick', {
|
|
57
65
|
id: 'unsigned',
|
|
@@ -88,7 +96,7 @@ async function apply(ctx, config) {
|
|
|
88
96
|
return `已经在烧砖了`;
|
|
89
97
|
}
|
|
90
98
|
users[user].burning = true;
|
|
91
|
-
await session.send(
|
|
99
|
+
await session.send(`${koishi_1.h.image('https://img3.tofaka.com/autoupload/ontjZmlK09ZHnuFOv9znC7KXl_QqVl-bpSwqP4fJO68/20260624/xsnm/447X447/images_%282%29.jpg/webp')}现在开始烧砖啦,群友每发送${config.cost}条消息就烧好一块砖`);
|
|
92
100
|
let messageCount = 0;
|
|
93
101
|
const dispose = ctx.guild(session.guildId).middleware(async (session_in, next) => {
|
|
94
102
|
if (![session.selfId, session.userId].includes(session_in.userId)) {
|
|
@@ -101,7 +109,7 @@ async function apply(ctx, config) {
|
|
|
101
109
|
brick: koishi_1.$.add(row.brick, 1),
|
|
102
110
|
}], ["userId", "guildId"]);
|
|
103
111
|
users[user].burning = false;
|
|
104
|
-
await session.send(`${koishi_1.h.
|
|
112
|
+
await session.send(`${koishi_1.h.image('https://img3.tofaka.com/autoupload/ontjZmlK09ZHnuFOv9znC7KXl_QqVl-bpSwqP4fJO68/20260624/xsnm/447X447/images_%282%29.jpg/webp')}${atUser(session, session.userId)} 砖已经烧好啦`);
|
|
105
113
|
}
|
|
106
114
|
}
|
|
107
115
|
return next();
|
|
@@ -148,14 +156,14 @@ async function apply(ctx, config) {
|
|
|
148
156
|
const brickImg = koishi_1.h.image('https://img3.tofaka.com/autoupload/ontjZmlK09ZHnuFOv9znC7KXl_QqVl-bpSwqP4fJO68/20260624/lOIl/240X240/images.jpg/webp');
|
|
149
157
|
if (koishi_1.Random.bool(probability)) {
|
|
150
158
|
const muteErr = await tryMute(session.userId);
|
|
151
|
-
let msg = `${brickImg}${
|
|
159
|
+
let msg = `${brickImg}${atUser(session, targetUserId)} 夺过你的砖头,把你拍晕了 ${muteTime} 秒`;
|
|
152
160
|
if (muteErr)
|
|
153
161
|
msg += '\n因为我不是群管理员,所以并没什么卵用';
|
|
154
162
|
return msg;
|
|
155
163
|
}
|
|
156
164
|
else {
|
|
157
165
|
const muteErr = await tryMute(targetUserId);
|
|
158
|
-
let msg = `${brickImg}${
|
|
166
|
+
let msg = `${brickImg}${atUser(session, targetUserId)} 你被 ${atUser(session, session.userId)} 拍晕了 ${muteTime} 秒`;
|
|
159
167
|
if (muteErr)
|
|
160
168
|
msg += '\n因为我不是群管理员,所以并没什么卵用';
|
|
161
169
|
return msg;
|
|
@@ -215,6 +223,7 @@ async function apply(ctx, config) {
|
|
|
215
223
|
const date = new Date();
|
|
216
224
|
const today = `${date.getFullYear()}-${date.getMonth() + 1}-${date.getDate()}`;
|
|
217
225
|
let brick = koishi_1.Random.int(config.minGain, config.maxGain + 1);
|
|
226
|
+
const signImg = koishi_1.h.image('https://img3.tofaka.com/autoupload/ontjZmlK09ZHnuFOv9znC7KXl_QqVl-bpSwqP4fJO68/20260624/yNf2/447X447/images_%281%29.jpg/webp');
|
|
218
227
|
const userData = await ctx.database.get('brick', {
|
|
219
228
|
userId: session.userId,
|
|
220
229
|
guildId: session.guildId,
|
|
@@ -226,7 +235,7 @@ async function apply(ctx, config) {
|
|
|
226
235
|
brick: brick,
|
|
227
236
|
checkingDay: today
|
|
228
237
|
});
|
|
229
|
-
return
|
|
238
|
+
return `${signImg}签到成功,你获得了 ${brick} 块砖头,现在有${brick}/${config.maxBrick}块砖头`;
|
|
230
239
|
}
|
|
231
240
|
if (userData[0].checkingDay === today) {
|
|
232
241
|
return "你今天已经签到过了";
|
|
@@ -246,7 +255,7 @@ async function apply(ctx, config) {
|
|
|
246
255
|
brick: koishi_1.$.add(row.brick, brick),
|
|
247
256
|
checkingDay: today
|
|
248
257
|
}], ["userId", "guildId"]);
|
|
249
|
-
return
|
|
258
|
+
return `${signImg}签到成功,你获得了 ${brick} 块砖头,现在有 ${userData[0].brick + brick}/${config.maxBrick} 块砖头`;
|
|
250
259
|
});
|
|
251
260
|
}
|
|
252
261
|
}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-ll-brick",
|
|
3
3
|
"description": "砖头拍人插件(克隆自 koishi-plugin-brick),非管理员时会提示",
|
|
4
|
-
"version": "1.0.
|
|
4
|
+
"version": "1.0.3",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|
|
7
7
|
"files": [
|
|
@@ -11,7 +11,7 @@
|
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"koishi": {
|
|
13
13
|
"description": {
|
|
14
|
-
"zh": "砖头拍人插件:烧砖、拍人、随机拍人、签到,修复了异步禁言bug
|
|
14
|
+
"zh": "砖头拍人插件:烧砖、拍人、随机拍人、签到,修复了异步禁言bug和QQ官方机器人艾特不生效问题"
|
|
15
15
|
}
|
|
16
16
|
},
|
|
17
17
|
"keywords": [
|
package/readme.md
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
# koishi-plugin-ll-brick
|
|
2
|
+
|
|
3
|
+
砖头拍人插件(克隆自 [koishi-plugin-brick](https://www.npmjs.com/package/koishi-plugin-brick))。
|
|
4
|
+
|
|
5
|
+
烧制砖块,然后拍晕群友!如果机器人没有禁言权限,会提示"没什么卵用"。
|
|
6
|
+
开始烧制之后,群内其他群友发送一定数量的消息就能完成烧制!
|
|
7
|
+
|
|
8
|
+
## 功能
|
|
9
|
+
|
|
10
|
+
- `砖头 烧砖` — 烧砖,需要群友聊天攒进度
|
|
11
|
+
- `砖头 拍人 @某人` — 用砖头拍晕(禁言)对方随机时间,有概率被反将一军
|
|
12
|
+
- `砖头 随机拍人` — 随机挑一个群友拍
|
|
13
|
+
- `砖头 查看` — 查看自己的砖头数量
|
|
14
|
+
- `砖头 签到`(可选开启)— 每日签到获取随机砖头
|
|
15
|
+
|
|
16
|
+
## v1.0.3 修复
|
|
17
|
+
|
|
18
|
+
- 修复 **QQ 官方机器人** 上回复消息中 @(艾特)不生效的问题:
|
|
19
|
+
- 原实现通过 koishi 的 `at` 元素发送,适配器会序列化成已弃用的 `<@openid>` 协议
|
|
20
|
+
- 现在 QQ 平台改用官方新格式 `<qqbot-at-user id="openid" />`,其他平台行为不变
|