jsbot-plugin-auto-reply-face 0.0.0-stage → 1.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 CHANGED
@@ -1,3 +1,28 @@
1
- # Temporary Holding Version
1
+ # jsbot_plugin_auto_reply_face
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ jsbot_plugin_auto_reply_face plugin
4
+
5
+ ## 开发
6
+
7
+ ```bash
8
+ npm install --prefix plugins/jsbot_plugin_auto_reply_face
9
+ ```
10
+
11
+ 启动根项目后,应用会自动从 `plugins/jsbot_plugin_auto_reply_face/dist` 加载本插件;如果此时还没有 `dist`,应用会先自动执行一次构建。
12
+
13
+ ## 配置
14
+
15
+ ```json
16
+ {
17
+ "plugins": {
18
+ "jsbot_plugin_auto_reply_face": {
19
+ "enabled": true,
20
+ "reply": "hello from jsbot_plugin_auto_reply_face"
21
+ }
22
+ }
23
+ }
24
+ ```
25
+
26
+ ## 发布到 npm
27
+
28
+ 准备发布时,删除 `private`,把包名 `@jsbot-tellus/plugin-jsbot_plugin_auto_reply_face` 改成自己的作用域,并确认 `dist/` 已包含在发布文件中。不要把 `@jsbot-tellus/core` 写进 `dependencies` 或 `peerDependencies`。
@@ -0,0 +1,3 @@
1
+ declare const _default: import("@jsbot-tellus/core").PluginDefinition<Record<string, never>, void>;
2
+ export default _default;
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":""}
package/dist/index.js ADDED
@@ -0,0 +1,95 @@
1
+ import { definePlugin } from '@jsbot-tellus/core';
2
+ import { isGroupMessageEvent, chain } from '@snowluma/sdk';
3
+ import { z } from 'zod';
4
+ const list_key = 'reply_list';
5
+ export default definePlugin({
6
+ manifest: {
7
+ id: 'jsbot_plugin_auto_reply_face',
8
+ version: '0.1.0',
9
+ description: 'auto reply face plugin',
10
+ defaultEnabled: true,
11
+ configSchema: z.object({}).strict(),
12
+ },
13
+ setup(ctx) {
14
+ ctx.commands.register({
15
+ name: 'test-reply',
16
+ permission: 'SuperAdmin',
17
+ params: '<message:reply><face:string>',
18
+ }, async (event, context, match, message, face) => {
19
+ if (!isGroupMessageEvent(event))
20
+ return;
21
+ await ctx.api.call('set_group_reaction', {
22
+ group_id: event.group_id,
23
+ message_id: message,
24
+ code: face,
25
+ });
26
+ });
27
+ ctx.commands.group({
28
+ name: 'auto-reply-list',
29
+ permission: 'SuperAdmin',
30
+ aliases: ['arl'],
31
+ }, (group) => {
32
+ group.register({
33
+ name: 'view',
34
+ }, async (event, context, match) => {
35
+ const list = ((await ctx.kv.get(list_key)) ??
36
+ []);
37
+ let message = chain().text('当前列表:').br();
38
+ for (const user of list) {
39
+ message = message.text(String(user)).br();
40
+ }
41
+ await context.send(message);
42
+ });
43
+ group.register({
44
+ name: 'add',
45
+ params: '<user:at>',
46
+ }, async (event, context, match, user) => {
47
+ const list = ((await ctx.kv.get(list_key)) ??
48
+ []);
49
+ if (list.includes(user))
50
+ await context.send(`${user} 已在名单内`);
51
+ else {
52
+ list.push(user);
53
+ await ctx.kv.set(list_key, list);
54
+ await context.send(`已将 ${user} 加入骚扰名单`);
55
+ }
56
+ });
57
+ group.register({
58
+ name: 'remove',
59
+ params: '<user:at>',
60
+ }, async (event, context, match, user) => {
61
+ const list = ((await ctx.kv.get(list_key)) ??
62
+ []);
63
+ if (!list.includes(user))
64
+ await context.send(`${user} 不在名单内`);
65
+ else {
66
+ await ctx.kv.set(list_key, list.filter((item) => item != user));
67
+ await context.send(`已将 ${user} 移出骚扰名单`);
68
+ }
69
+ });
70
+ });
71
+ ctx.events.onGroupMessage(async (event, _context) => {
72
+ const user = event.user_id;
73
+ const list = ((await ctx.kv.get(list_key)) ?? []);
74
+ if (list.includes(user)) {
75
+ ctx.tasks.enqueue(`auto-reply-face:${user}`, async (signal) => {
76
+ // await new Promise<void>((resolve) => { setTimeout(resolve, 500) })
77
+ for (let i = 20; i < 40; ++i) {
78
+ try {
79
+ if (signal.aborted)
80
+ break;
81
+ await ctx.api.call('set_msg_emoji_like', {
82
+ message_id: event.message_id,
83
+ emoji_id: String(i),
84
+ });
85
+ }
86
+ catch {
87
+ continue;
88
+ }
89
+ }
90
+ });
91
+ }
92
+ });
93
+ },
94
+ });
95
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAA;AACjD,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,MAAM,eAAe,CAAA;AAC1D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB,MAAM,QAAQ,GAAG,YAAY,CAAA;AAE7B,eAAe,YAAY,CAAC;IACxB,QAAQ,EAAE;QACN,EAAE,EAAE,8BAA8B;QAClC,OAAO,EAAE,OAAO;QAChB,WAAW,EAAE,wBAAwB;QACrC,cAAc,EAAE,IAAI;QACpB,YAAY,EAAE,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC,MAAM,EAAE;KACtC;IAED,KAAK,CAAC,GAAG;QACL,GAAG,CAAC,QAAQ,CAAC,QAAQ,CACjB;YACI,IAAI,EAAE,YAAY;YAClB,UAAU,EAAE,YAAY;YACxB,MAAM,EAAE,8BAA8B;SACzC,EACD,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAE,IAAI,EAAE,EAAE;YAC3C,IAAI,CAAC,mBAAmB,CAAC,KAAK,CAAC;gBAAE,OAAM;YACvC,MAAM,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE;gBACrC,QAAQ,EAAE,KAAK,CAAC,QAAQ;gBACxB,UAAU,EAAE,OAAO;gBACnB,IAAI,EAAE,IAAI;aACb,CAAC,CAAA;QACN,CAA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AE,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE;oBAC1D,qEAAqE;oBACrE,KAAK,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;wBAC3B,IAAI,CAAC;4BACD,IAAI,MAAM,CAAC,OAAO;gCAAE,MAAK;4BACzB,MAAM,GAAG,CAAC,GAAG,CAAC,IAAI,CAAC,oBAAoB,EAAE;gCACrC,UAAU,EAAE,KAAK,CAAC,UAAU;gCAC5B,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAC;6BACtB,CAAC,CAAA;wBACN,CAAC;wBAAC,MAAM,CAAC;4BACL,SAAQ;wBACZ,CAAC;oBACL,CAAC;gBACL,CAAC,CAAC,CAAA;YACN,CAAC;QACL,CAAC,CAAC,CAAA;IACN,CAAC;CACJ,CAAC,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,30 @@
1
1
  {
2
- "name": "jsbot-plugin-auto-reply-face",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
2
+ "name": "jsbot-plugin-auto-reply-face",
3
+ "version": "1.0.0",
4
+ "description": "auto reply face plugin",
5
+ "type": "module",
6
+ "main": "./dist/index.js",
7
+ "types": "./dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsc -p tsconfig.json",
19
+ "check": "tsc -p tsconfig.json --noEmit",
20
+ "watch": "tsc -p tsconfig.json --watch"
21
+ },
22
+ "devDependencies": {
23
+ "@jsbot-tellus/core": "^2.7.0",
24
+ "@types/node": "^24.6.4",
25
+ "typescript": "^7.0.2"
26
+ },
27
+ "dependencies": {
28
+ "zod": "^4.6.7"
29
+ }
30
+ }