@alemonjs/kook 0.0.1 → 0.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/README.md ADDED
@@ -0,0 +1,34 @@
1
+ # [https://alemonjs.com/](https://alemonjs.com/)
2
+
3
+ 跨平台开发的事件驱动机器人
4
+
5
+ ## USE
6
+
7
+ - kook
8
+
9
+ ```sh
10
+ yarn add @alemonjs/kook
11
+ ```
12
+
13
+ - alemon.config.yaml
14
+
15
+ ```sh
16
+ kook:
17
+ # 令牌
18
+ token: ''
19
+ ```
20
+
21
+ > 完整的
22
+
23
+ ```sh
24
+ kook:
25
+ # 令牌
26
+ token: ''
27
+ # 主人
28
+ master_id:
29
+ - ''
30
+ ```
31
+
32
+ ## Community
33
+
34
+ QQ Group 806943302
package/lib/index.d.ts CHANGED
@@ -1,9 +1,3 @@
1
- import { ConfigType } from 'alemonjs';
1
+ declare const _default: () => typeof global.alemonjs;
2
2
 
3
- /**
4
- *
5
- * @param val
6
- */
7
- declare const login: (config: ConfigType) => void;
8
-
9
- export { login };
3
+ export { _default as default };
package/lib/index.js CHANGED
@@ -1,11 +1,11 @@
1
- import { Text, At, OnProcessor, useParse } from 'alemonjs';
1
+ import { defineBot, getConfig, Text, At, OnProcessor, useParse } from 'alemonjs';
2
2
  import { KOOKClient } from 'chat-space';
3
3
 
4
- /**
5
- *
6
- * @param val
7
- */
8
- const login = (config) => {
4
+ var index = defineBot(() => {
5
+ const cfg = getConfig();
6
+ const config = cfg.value?.kook;
7
+ if (!config)
8
+ return;
9
9
  // 创建客户端
10
10
  const client = new KOOKClient({
11
11
  token: config.token
@@ -98,45 +98,40 @@ const login = (config) => {
98
98
  client.on('ERROR', msg => {
99
99
  console.error(msg);
100
100
  });
101
- /**
102
- * 开始实现全局接口
103
- */
104
- if (!global?.alemonjs) {
105
- global.alemonjs = {
106
- api: {
107
- use: {
108
- send: (event, val) => {
109
- if (val.length < 0)
110
- return;
111
- const content = useParse(val, 'Text');
112
- if (content) {
113
- return client.createMessage({
114
- type: 9,
101
+ return {
102
+ api: {
103
+ use: {
104
+ send: (event, val) => {
105
+ if (val.length < 0)
106
+ return Promise.all([]);
107
+ const content = useParse(val, 'Text');
108
+ if (content) {
109
+ return Promise.all([content].map(item => client.createMessage({
110
+ type: 9,
111
+ target_id: event.ChannelId,
112
+ content: item
113
+ })));
114
+ }
115
+ const images = useParse(val, 'Image');
116
+ if (images) {
117
+ return Promise.all(images.map(async (item) => {
118
+ // 上传图片
119
+ const res = await client.postImage(item);
120
+ if (!res)
121
+ return Promise.resolve();
122
+ // 发送消息
123
+ return await client.createMessage({
124
+ type: 2,
115
125
  target_id: event.ChannelId,
116
- content: content
126
+ content: res.data.url
117
127
  });
118
- }
119
- const images = useParse(val, 'Image');
120
- if (images) {
121
- return Promise.all(images.map(async (item) => {
122
- // 上传图片
123
- const res = await client.postImage(item);
124
- if (!res)
125
- return Promise.resolve();
126
- // 发送消息
127
- return await client.createMessage({
128
- type: 2,
129
- target_id: event.ChannelId,
130
- content: res.data.url
131
- });
132
- }));
133
- }
134
- return Promise.resolve();
128
+ }));
135
129
  }
130
+ return Promise.all([]);
136
131
  }
137
132
  }
138
- };
139
- }
140
- };
133
+ }
134
+ };
135
+ });
141
136
 
142
- export { login };
137
+ export { index as default };
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@alemonjs/kook",
3
- "version": "0.0.1",
4
- "description": "啊柠檬脚本",
5
- "author": "ningmengchongshui",
3
+ "version": "0.0.3",
4
+ "description": "kook-bot",
5
+ "author": "lemonade",
6
6
  "license": "MIT",
7
7
  "type": "module",
8
8
  "main": "lib/index.js",
9
9
  "dependencies": {
10
- "chat-space": "^0.0.3"
10
+ "chat-space": "^0.0.6"
11
11
  },
12
12
  "types": "lib",
13
13
  "exports": {
@@ -16,8 +16,18 @@
16
16
  "types": "./lib/index.d.ts"
17
17
  }
18
18
  },
19
+ "keywords": [
20
+ "alemonjs",
21
+ "kook",
22
+ "bot",
23
+ "chat-bot"
24
+ ],
19
25
  "publishConfig": {
20
- "access": "public",
21
26
  "registry": "https://registry.npmjs.org"
27
+ },
28
+ "bugs": "https://github.com/ningmengchongshui/alemonjs/issues",
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/ningmengchongshui/alemonjs.git"
22
32
  }
23
33
  }