node-karin 0.6.22 → 0.6.24
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 +8 -10
- package/lib/adapter/onebot/11/convert.js +1 -1
- package/lib/adapter/onebot/11/event.js +15 -0
- package/lib/utils/common.d.ts +2 -2
- package/lib/utils/common.js +2 -2
- package/lib/utils/init.js +1 -1
- package/lib/utils/segment.d.ts +3 -3
- package/lib/utils/segment.js +2 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -4,7 +4,9 @@
|
|
|
4
4
|
|
|
5
5
|
基于 [Kritor](https://github.com/KarinJS/kritor-kotlin) 标准进行开发的 [nodejs](https://nodejs.org/en) 机器人框架
|
|
6
6
|
|
|
7
|
-
>
|
|
7
|
+
> 本项目正在开发中,现阶段我并不能为你解决任何问题,谨慎使用。
|
|
8
|
+
> 此项目不想成为、代替任何项目,也没有这个能力,请别造谣。
|
|
9
|
+
> ~~不欢迎某些人,勿扰谢谢(ps: )~~
|
|
8
10
|
|
|
9
11
|
---
|
|
10
12
|
|
|
@@ -19,21 +21,18 @@
|
|
|
19
21
|
- [x] 支持被动ws
|
|
20
22
|
- [ ] 支持onebot HTTP
|
|
21
23
|
- [x] 支持[onebots](https://github.com/lc-cn/onebots)
|
|
22
|
-
- [x] ~~puppeteer渲染图片~~
|
|
23
24
|
- [x] 外置[puppeteer](https://github.com/KarinJS/karin-plugin-puppeteer)
|
|
24
|
-
- [
|
|
25
|
-
- [
|
|
26
|
-
- [ ]
|
|
27
|
-
- [ ]
|
|
25
|
+
- [x] 降低对`redis`的依赖,开始逐渐抛弃redis
|
|
26
|
+
- [x] 支持 package.karin
|
|
27
|
+
- [ ] ~~支持db通用接口~~
|
|
28
|
+
- [ ] ~~支持动态加载插件~~
|
|
28
29
|
- [x] 支持`redis`集群
|
|
29
30
|
|
|
30
|
-
> 关于`puppeteer`,由于内置的chrome过于臃肿,将会移除内置的pupppeteer,分开搭建或使用远程、作为插件等方式使用puppeteer。
|
|
31
|
-
> [karin-puppeteer](https://github.com/KarinJS/karin-puppeteer)
|
|
32
|
-
|
|
33
31
|
### 感谢
|
|
34
32
|
|
|
35
33
|
Karin的开发离不开以下项目的帮助:
|
|
36
34
|
|
|
35
|
+
- [icqqjs](https://github.com/icqqjs)
|
|
37
36
|
- [Kritor](https://github.com/KarinJS/kritor) Kritor标准
|
|
38
37
|
- [OpenShamrock](https://github.com/whitechi73/OpenShamrock) Kritor标准Kotlin的实现
|
|
39
38
|
- [onebots](https://github.com/lc-cn/onebots) onebots适配器
|
|
@@ -47,7 +46,6 @@ QQGroup: 967068507
|
|
|
47
46
|
|
|
48
47
|
Discord: [☘Karin的喵趴~](https://discord.com/channels/1251552521957408878/1251552521957408881)
|
|
49
48
|
|
|
50
|
-
|
|
51
49
|
### 贡献者
|
|
52
50
|
|
|
53
51
|
> 🌟星光闪烁,你们的智慧如同璀璨的夜空。感谢所有为**Karin**做出贡献的人!
|
|
@@ -17,7 +17,7 @@ export function AdapterConvertKarin(data) {
|
|
|
17
17
|
elements.push(segment.image(i.data.url || i.data.file, { file_type: i.data.type }));
|
|
18
18
|
break;
|
|
19
19
|
case 'record':
|
|
20
|
-
elements.push(segment.
|
|
20
|
+
elements.push(segment.record(i.data.url || i.data.file, i.data.magic === 1));
|
|
21
21
|
break;
|
|
22
22
|
case 'video':
|
|
23
23
|
elements.push(segment.video(i.data.url || i.data.file));
|
|
@@ -353,6 +353,11 @@ export class OB11Event {
|
|
|
353
353
|
return this.adapter.logger('error', '未知通知事件:', JSON.stringify(data));
|
|
354
354
|
}
|
|
355
355
|
}
|
|
356
|
+
notice.bot = this.adapter;
|
|
357
|
+
/**
|
|
358
|
+
* 快速回复 开发者不应该使用这个方法,应该使用由karin封装过后的reply方法
|
|
359
|
+
*/
|
|
360
|
+
notice.replyCallback = async (elements) => await this.adapter.SendMessage(notice.contact, elements);
|
|
356
361
|
listener.emit('notice', notice);
|
|
357
362
|
}
|
|
358
363
|
/** 请求事件 */
|
|
@@ -383,6 +388,11 @@ export class OB11Event {
|
|
|
383
388
|
message: data.comment,
|
|
384
389
|
},
|
|
385
390
|
});
|
|
391
|
+
request.bot = this.adapter;
|
|
392
|
+
/**
|
|
393
|
+
* 快速回复 开发者不应该使用这个方法,应该使用由karin封装过后的reply方法
|
|
394
|
+
*/
|
|
395
|
+
request.replyCallback = async (elements) => await this.adapter.SendMessage(request.contact, elements);
|
|
386
396
|
listener.emit('request', request);
|
|
387
397
|
return;
|
|
388
398
|
}
|
|
@@ -414,6 +424,11 @@ export class OB11Event {
|
|
|
414
424
|
message: data.comment,
|
|
415
425
|
},
|
|
416
426
|
});
|
|
427
|
+
request.bot = this.adapter;
|
|
428
|
+
/**
|
|
429
|
+
* 快速回复 开发者不应该使用这个方法,应该使用由karin封装过后的reply方法
|
|
430
|
+
*/
|
|
431
|
+
request.replyCallback = async (elements) => await this.adapter.SendMessage(request.contact, elements);
|
|
417
432
|
listener.emit('request', request);
|
|
418
433
|
return;
|
|
419
434
|
}
|
package/lib/utils/common.d.ts
CHANGED
|
@@ -131,8 +131,8 @@ export declare const common: {
|
|
|
131
131
|
/**
|
|
132
132
|
* 制作简单转发,返回segment.node[]。仅简单包装node,也可以自己组装
|
|
133
133
|
* @param elements
|
|
134
|
-
* @param fakeUin
|
|
135
|
-
* @param fakeNick
|
|
134
|
+
* @param fakeUin 转发用户的QQ号 必填
|
|
135
|
+
* @param fakeNick 转发用户显示的昵称 必填
|
|
136
136
|
*/
|
|
137
137
|
makeForward(elements: KarinElement | KarinElement[], fakeUin: string, fakeNick: string): Array<NodeElement>;
|
|
138
138
|
/**
|
package/lib/utils/common.js
CHANGED
|
@@ -352,8 +352,8 @@ export const common = new (class Common {
|
|
|
352
352
|
/**
|
|
353
353
|
* 制作简单转发,返回segment.node[]。仅简单包装node,也可以自己组装
|
|
354
354
|
* @param elements
|
|
355
|
-
* @param fakeUin
|
|
356
|
-
* @param fakeNick
|
|
355
|
+
* @param fakeUin 转发用户的QQ号 必填
|
|
356
|
+
* @param fakeNick 转发用户显示的昵称 必填
|
|
357
357
|
*/
|
|
358
358
|
makeForward (elements, fakeUin, fakeNick) {
|
|
359
359
|
if (!Array.isArray(elements)) { elements = [elements] }
|
package/lib/utils/init.js
CHANGED
|
@@ -201,7 +201,7 @@ export class KarinInit {
|
|
|
201
201
|
* 获取当前的包管理器 根据锁文件判断
|
|
202
202
|
*/
|
|
203
203
|
getRegistry () {
|
|
204
|
-
if (fs.existsSync('./pnpm-lock')) { return 'pnpm' }
|
|
204
|
+
if (fs.existsSync('./pnpm-lock.yaml')) { return 'pnpm' }
|
|
205
205
|
if (fs.existsSync('./yarn.lock')) { return 'yarn' }
|
|
206
206
|
if (fs.existsSync('./package-lock.json')) { return 'npm' }
|
|
207
207
|
// cnpm 没有锁文件
|
package/lib/utils/segment.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { TextElement, AtElement, ImageElement, FaceElement, BubbleFaceElement, ReplyElement,
|
|
1
|
+
import { TextElement, AtElement, ImageElement, FaceElement, BubbleFaceElement, ReplyElement, VideoElement, BasketballElement, DiceElement, RpsElement, PokeElement, MusicElement, WeatherElement, LocationElement, ShareElement, GiftElement, MarketFaceElement, ForwardElement, ContactElement, JsonElement, XmlElement, FileElement, ButtonElement, CustomMusicElemen, TemplateElement, ContentElement, NodeElement, KarinElement, LongMsgElement, RecordElement } from '../types/index.js';
|
|
2
2
|
export declare const segment: {
|
|
3
3
|
/**
|
|
4
4
|
* 纯文本
|
|
@@ -77,7 +77,7 @@ export declare const segment: {
|
|
|
77
77
|
* @param name - 语音名称
|
|
78
78
|
* @returns {VoiceElement} 语音元素
|
|
79
79
|
*/
|
|
80
|
-
record(file: string, magic?: boolean, md5?: string, name?: string):
|
|
80
|
+
record(file: string, magic?: boolean, md5?: string, name?: string): RecordElement;
|
|
81
81
|
/**
|
|
82
82
|
* 语音 即将废弃 请使用segment.record
|
|
83
83
|
* @param file - 语音URL或路径、Base64
|
|
@@ -87,7 +87,7 @@ export declare const segment: {
|
|
|
87
87
|
* @returns {VoiceElement} 语音元素
|
|
88
88
|
* @deprecated 即将废弃 请使用segment.record
|
|
89
89
|
*/
|
|
90
|
-
voice(file: string, magic?: boolean, md5?: string, name?: string):
|
|
90
|
+
voice(file: string, magic?: boolean, md5?: string, name?: string): RecordElement;
|
|
91
91
|
/**
|
|
92
92
|
* 视频
|
|
93
93
|
* @param file - 视频URL或路径、Base64
|
package/lib/utils/segment.js
CHANGED
|
@@ -105,7 +105,7 @@ export const segment = new (class Segment {
|
|
|
105
105
|
*/
|
|
106
106
|
record (file, magic = false, md5 = '', name = '') {
|
|
107
107
|
return {
|
|
108
|
-
type: '
|
|
108
|
+
type: 'record',
|
|
109
109
|
file,
|
|
110
110
|
magic,
|
|
111
111
|
md5,
|
|
@@ -124,7 +124,7 @@ export const segment = new (class Segment {
|
|
|
124
124
|
*/
|
|
125
125
|
voice (file, magic = false, md5 = '', name = '') {
|
|
126
126
|
return {
|
|
127
|
-
type: '
|
|
127
|
+
type: 'record',
|
|
128
128
|
file,
|
|
129
129
|
magic,
|
|
130
130
|
md5,
|