node-karin 0.12.0 → 0.12.2-5.pr.206.027f2f2
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/CHANGELOG.md +1029 -0
- package/default/comment/config.json +34 -0
- package/default/comment/friendDirect.json +10 -0
- package/default/comment/groupGuild.json +11 -0
- package/default/comment/server.json +17 -0
- package/default/config/adapter.json +28 -0
- package/default/config/config.json +47 -0
- package/default/config/groups.json +47 -0
- package/default/config/groups.yaml +70 -0
- package/default/config/pm2.json +16 -0
- package/default/config/privates.json +23 -0
- package/default/config/privates.yaml +31 -0
- package/default/config/redis.json +10 -0
- package/default/config/render.json +19 -0
- package/default/view/group.yaml +73 -0
- package/dist/index.d.ts +9869 -0
- package/dist/index.js +12643 -0
- package/dist/module/art-template.cjs +11 -0
- package/dist/module/art-template.d.ts +1 -0
- package/dist/module/axios.cjs +22 -0
- package/dist/module/axios.d.ts +2 -0
- package/dist/module/chalk.cjs +22 -0
- package/dist/module/chalk.d.ts +2 -0
- package/dist/module/chokidar.cjs +22 -0
- package/dist/module/chokidar.d.ts +2 -0
- package/dist/module/commander.cjs +35 -0
- package/dist/module/commander.d.ts +3 -0
- package/dist/module/commander.js +3 -0
- package/dist/module/dotenv.cjs +22 -0
- package/dist/module/dotenv.d.ts +2 -0
- package/dist/module/dotenv.js +2 -0
- package/dist/module/express.cjs +112 -0
- package/dist/module/express.d.ts +1 -0
- package/dist/module/express.js +1 -0
- package/dist/module/level.cjs +22 -0
- package/dist/module/level.d.ts +2 -0
- package/dist/module/lodash.cjs +11 -0
- package/dist/module/lodash.d.ts +1 -0
- package/dist/module/log4js.cjs +22 -0
- package/dist/module/log4js.d.ts +2 -0
- package/dist/module/moment.cjs +11 -0
- package/dist/module/moment.d.ts +1 -0
- package/dist/module/node-schedule.cjs +22 -0
- package/dist/module/node-schedule.d.ts +2 -0
- package/dist/module/redis.cjs +22 -0
- package/dist/module/redis.d.ts +2 -0
- package/dist/module/ws.cjs +28 -0
- package/dist/module/ws.d.ts +1 -0
- package/dist/module/ws.js +1 -0
- package/dist/module/yaml.cjs +22 -0
- package/dist/module/yaml.d.ts +2 -0
- package/dist/root.d.ts +40 -0
- package/dist/root.js +44 -0
- package/package.json +142 -128
- package/LICENSE +0 -674
- package/README.md +0 -56
- package/config/defSet/App.yaml +0 -42
- package/config/defSet/config.yaml +0 -65
- package/config/defSet/group.yaml +0 -56
- package/config/defSet/pm2.yaml +0 -21
- package/config/defSet/redis.yaml +0 -18
- package/config/defSet/server.yaml +0 -42
- package/config/view/group.yaml +0 -92
- package/lib/adapter/index.d.ts +0 -2
- package/lib/adapter/index.js +0 -2
- package/lib/adapter/input/index.d.ts +0 -78
- package/lib/adapter/input/index.js +0 -205
- package/lib/adapter/onebot/11/convert.d.ts +0 -12
- package/lib/adapter/onebot/11/convert.js +0 -167
- package/lib/adapter/onebot/11/event.d.ts +0 -25
- package/lib/adapter/onebot/11/event.js +0 -442
- package/lib/adapter/onebot/11/index.d.ts +0 -508
- package/lib/adapter/onebot/11/index.js +0 -1047
- package/lib/cli/index.d.ts +0 -92
- package/lib/cli/index.js +0 -307
- package/lib/cli/init.d.ts +0 -2
- package/lib/cli/init.js +0 -22
- package/lib/cli/karin.d.ts +0 -2
- package/lib/cli/karin.js +0 -16
- package/lib/cli/pkg.d.ts +0 -4
- package/lib/cli/pkg.js +0 -14
- package/lib/cli/start.d.ts +0 -1
- package/lib/cli/start.js +0 -8
- package/lib/core/index.d.ts +0 -10
- package/lib/core/index.js +0 -10
- package/lib/core/init/config.d.ts +0 -43
- package/lib/core/init/config.js +0 -201
- package/lib/core/init/dir.d.ts +0 -4
- package/lib/core/init/dir.js +0 -7
- package/lib/core/init/init.d.ts +0 -1
- package/lib/core/init/init.js +0 -47
- package/lib/core/karin/karin.d.ts +0 -198
- package/lib/core/karin/karin.js +0 -226
- package/lib/core/listener/listener.d.ts +0 -145
- package/lib/core/listener/listener.js +0 -235
- package/lib/core/plugin/base.d.ts +0 -156
- package/lib/core/plugin/base.js +0 -131
- package/lib/core/plugin/loader.d.ts +0 -141
- package/lib/core/plugin/loader.js +0 -618
- package/lib/core/process/process.d.ts +0 -18
- package/lib/core/process/process.js +0 -96
- package/lib/core/server/server.d.ts +0 -25
- package/lib/core/server/server.js +0 -295
- package/lib/db/index.d.ts +0 -2
- package/lib/db/index.js +0 -2
- package/lib/db/level/level.d.ts +0 -19
- package/lib/db/level/level.js +0 -36
- package/lib/db/redis/redis.d.ts +0 -2
- package/lib/db/redis/redis.js +0 -135
- package/lib/db/redis/redis_level.d.ts +0 -112
- package/lib/db/redis/redis_level.js +0 -281
- package/lib/event/handler/base.d.ts +0 -42
- package/lib/event/handler/base.js +0 -200
- package/lib/event/handler/message.d.ts +0 -29
- package/lib/event/handler/message.js +0 -307
- package/lib/event/handler/notice.d.ts +0 -18
- package/lib/event/handler/notice.js +0 -214
- package/lib/event/handler/request.d.ts +0 -18
- package/lib/event/handler/request.js +0 -115
- package/lib/event/handler/review.d.ts +0 -55
- package/lib/event/handler/review.js +0 -386
- package/lib/event/index.d.ts +0 -5
- package/lib/event/index.js +0 -5
- package/lib/index.d.ts +0 -8
- package/lib/index.js +0 -8
- package/lib/modules/art-template.d.ts +0 -1
- package/lib/modules/axios.d.ts +0 -2
- package/lib/modules/chalk.d.ts +0 -2
- package/lib/modules/chokidar.d.ts +0 -2
- package/lib/modules/commander.d.ts +0 -2
- package/lib/modules/commander.js +0 -2
- package/lib/modules/express.d.ts +0 -3
- package/lib/modules/express.js +0 -3
- package/lib/modules/level.d.ts +0 -2
- package/lib/modules/lodash.d.ts +0 -1
- package/lib/modules/log4js.d.ts +0 -2
- package/lib/modules/moment.d.ts +0 -1
- package/lib/modules/node-schedule.d.ts +0 -2
- package/lib/modules/redis.d.ts +0 -2
- package/lib/modules/ws.d.ts +0 -3
- package/lib/modules/ws.js +0 -3
- package/lib/modules/yaml.d.ts +0 -2
- package/lib/modules.d.ts +0 -15
- package/lib/modules.js +0 -15
- package/lib/render/app.d.ts +0 -56
- package/lib/render/app.js +0 -120
- package/lib/render/base.d.ts +0 -30
- package/lib/render/base.js +0 -69
- package/lib/render/client.d.ts +0 -41
- package/lib/render/client.js +0 -238
- package/lib/render/http.d.ts +0 -19
- package/lib/render/http.js +0 -50
- package/lib/render/index.d.ts +0 -6
- package/lib/render/index.js +0 -6
- package/lib/render/server.d.ts +0 -25
- package/lib/render/server.js +0 -101
- package/lib/render/wormhole.d.ts +0 -1
- package/lib/render/wormhole.js +0 -156
- package/lib/types/adapter/api.d.ts +0 -399
- package/lib/types/adapter/api.js +0 -1
- package/lib/types/adapter/base.d.ts +0 -560
- package/lib/types/adapter/base.js +0 -1
- package/lib/types/config/config.d.ts +0 -379
- package/lib/types/config/config.js +0 -1
- package/lib/types/element/element.d.ts +0 -565
- package/lib/types/element/element.js +0 -1
- package/lib/types/element/qqbot.d.ts +0 -123
- package/lib/types/element/qqbot.js +0 -1
- package/lib/types/event/contact.d.ts +0 -28
- package/lib/types/event/contact.js +0 -1
- package/lib/types/event/event.d.ts +0 -305
- package/lib/types/event/event.js +0 -1
- package/lib/types/event/index.d.ts +0 -12
- package/lib/types/event/index.js +0 -7
- package/lib/types/event/message.d.ts +0 -109
- package/lib/types/event/message.js +0 -74
- package/lib/types/event/notice.d.ts +0 -513
- package/lib/types/event/notice.js +0 -52
- package/lib/types/event/reply.d.ts +0 -50
- package/lib/types/event/reply.js +0 -1
- package/lib/types/event/request.d.ts +0 -126
- package/lib/types/event/request.js +0 -52
- package/lib/types/event/sender.d.ts +0 -44
- package/lib/types/event/sender.js +0 -1
- package/lib/types/index.d.ts +0 -13
- package/lib/types/index.js +0 -13
- package/lib/types/logger/logger.d.ts +0 -110
- package/lib/types/logger/logger.js +0 -1
- package/lib/types/onebot11/api.d.ts +0 -53
- package/lib/types/onebot11/api.js +0 -1
- package/lib/types/onebot11/event.d.ts +0 -619
- package/lib/types/onebot11/event.js +0 -2
- package/lib/types/onebot11/index.d.ts +0 -6
- package/lib/types/onebot11/index.js +0 -6
- package/lib/types/onebot11/params.d.ts +0 -609
- package/lib/types/onebot11/params.js +0 -1
- package/lib/types/onebot11/response.d.ts +0 -516
- package/lib/types/onebot11/response.js +0 -1
- package/lib/types/onebot11/segment.d.ts +0 -269
- package/lib/types/onebot11/segment.js +0 -1
- package/lib/types/onebot11/sender.d.ts +0 -59
- package/lib/types/onebot11/sender.js +0 -1
- package/lib/types/plugin/app.d.ts +0 -71
- package/lib/types/plugin/app.js +0 -1
- package/lib/types/plugin/plugin.d.ts +0 -473
- package/lib/types/plugin/plugin.js +0 -1
- package/lib/types/render/render.d.ts +0 -118
- package/lib/types/render/render.js +0 -1
- package/lib/types/type/global.d.ts +0 -25
- package/lib/types/type/global.js +0 -1
- package/lib/utils/common/common.d.ts +0 -236
- package/lib/utils/common/common.js +0 -708
- package/lib/utils/config/config.d.ts +0 -193
- package/lib/utils/config/config.js +0 -328
- package/lib/utils/config/updateVersion.d.ts +0 -33
- package/lib/utils/config/updateVersion.js +0 -145
- package/lib/utils/config/yamlEditor.d.ts +0 -101
- package/lib/utils/config/yamlEditor.js +0 -330
- package/lib/utils/core/handler.d.ts +0 -18
- package/lib/utils/core/handler.js +0 -46
- package/lib/utils/core/logger.d.ts +0 -3
- package/lib/utils/core/logger.js +0 -105
- package/lib/utils/core/segment.d.ts +0 -279
- package/lib/utils/core/segment.js +0 -451
- package/lib/utils/index.d.ts +0 -13
- package/lib/utils/index.js +0 -13
- package/lib/utils/tools/button.d.ts +0 -2
- package/lib/utils/tools/button.js +0 -27
- package/lib/utils/tools/exec.d.ts +0 -20
- package/lib/utils/tools/exec.js +0 -54
- package/lib/utils/tools/ffmpeg.d.ts +0 -12
- package/lib/utils/tools/ffmpeg.js +0 -25
- package/lib/utils/tools/restart.d.ts +0 -15
- package/lib/utils/tools/restart.js +0 -39
- package/lib/utils/tools/stop.d.ts +0 -7
- package/lib/utils/tools/stop.js +0 -13
- package/lib/utils/tools/update.d.ts +0 -67
- package/lib/utils/tools/update.js +0 -151
- /package/{config → default}/view/App.yaml +0 -0
- /package/{config → default}/view/config.yaml +0 -0
- /package/{config → default}/view/pm2.yaml +0 -0
- /package/{config → default}/view/redis.yaml +0 -0
- /package/{config → default}/view/server.yaml +0 -0
- /package/{lib/modules → dist/module}/art-template.js +0 -0
- /package/{lib/modules → dist/module}/axios.js +0 -0
- /package/{lib/modules → dist/module}/chalk.js +0 -0
- /package/{lib/modules → dist/module}/chokidar.js +0 -0
- /package/{lib/modules → dist/module}/level.js +0 -0
- /package/{lib/modules → dist/module}/lodash.js +0 -0
- /package/{lib/modules → dist/module}/log4js.js +0 -0
- /package/{lib/modules → dist/module}/moment.js +0 -0
- /package/{lib/modules → dist/module}/node-schedule.js +0 -0
- /package/{lib/modules → dist/module}/redis.js +0 -0
- /package/{lib/modules → dist/module}/yaml.js +0 -0
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import { randomUUID } from 'crypto';
|
|
3
|
-
import { listener } from '../../core/index.js';
|
|
4
|
-
import { config, common, YamlEditor, logger } from '../../utils/index.js';
|
|
5
|
-
import { KarinMessage } from '../../types/index.js';
|
|
6
|
-
const { enable, msgToFile, token: oldToken, ip } = config.Config.AdapterInput;
|
|
7
|
-
/**
|
|
8
|
-
* - 标准输入输出适配器
|
|
9
|
-
*/
|
|
10
|
-
export class AdapterInput {
|
|
11
|
-
token;
|
|
12
|
-
socket;
|
|
13
|
-
account;
|
|
14
|
-
adapter;
|
|
15
|
-
version;
|
|
16
|
-
constructor() {
|
|
17
|
-
this.token = oldToken;
|
|
18
|
-
this.account = { uid: 'input', uin: 'input', name: 'input' };
|
|
19
|
-
this.adapter = { id: 'shell', name: 'input', type: 'internal', sub_type: 'internal', start_time: Date.now(), connect: '', index: 0 };
|
|
20
|
-
this.version = { name: 'input', app_name: 'input', version: '1.0.0' };
|
|
21
|
-
}
|
|
22
|
-
get self_id() {
|
|
23
|
-
return this.account.uid;
|
|
24
|
-
}
|
|
25
|
-
stdin() {
|
|
26
|
-
if (oldToken === 'AdapterInput') {
|
|
27
|
-
try {
|
|
28
|
-
this.token = randomUUID();
|
|
29
|
-
const yaml = new YamlEditor('./config/config/config.yaml');
|
|
30
|
-
const data = yaml.get('AdapterInput');
|
|
31
|
-
if (!data) {
|
|
32
|
-
const yaml1 = new YamlEditor('./config/defSet/config.yaml');
|
|
33
|
-
const data1 = yaml1.get('AdapterInput');
|
|
34
|
-
data1.token = this.token;
|
|
35
|
-
yaml.set('AdapterInput', data1);
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
data.token = this.token;
|
|
39
|
-
yaml.set('AdapterInput', data);
|
|
40
|
-
}
|
|
41
|
-
yaml.save();
|
|
42
|
-
}
|
|
43
|
-
catch (e) {
|
|
44
|
-
logger.error('AdapterInput token更换失败,请手动更换token');
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
// 清空文件夹
|
|
48
|
-
fs.readdirSync('./temp/input').forEach((file) => {
|
|
49
|
-
fs.unlinkSync(`./temp/input/${file}`);
|
|
50
|
-
});
|
|
51
|
-
// 等1秒
|
|
52
|
-
common.sleep(1000)
|
|
53
|
-
.then(() => {
|
|
54
|
-
/** 注册bot */
|
|
55
|
-
const index = listener.addBot({ bot: this, type: this.adapter.type });
|
|
56
|
-
if (index)
|
|
57
|
-
this.adapter.index = index;
|
|
58
|
-
});
|
|
59
|
-
return this;
|
|
60
|
-
}
|
|
61
|
-
init() {
|
|
62
|
-
process.stdin.on('data', data => this.#input(data.toString()));
|
|
63
|
-
process.once('stdin.close', () => {
|
|
64
|
-
process.stdin.removeAllListeners('data');
|
|
65
|
-
process.stdin.once('stdin.open', () => this.init());
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
logger(level, ...args) {
|
|
69
|
-
logger.bot(level, this.account.uid || this.account.uin, ...args);
|
|
70
|
-
}
|
|
71
|
-
async #input(elements) {
|
|
72
|
-
const message = {
|
|
73
|
-
event: "message" /* EventType.Message */,
|
|
74
|
-
sub_event: "private_message" /* MessageSubType.PrivateMessage */,
|
|
75
|
-
event_id: `input.${Date.now()}`,
|
|
76
|
-
self_id: 'input',
|
|
77
|
-
user_id: 'input',
|
|
78
|
-
time: Date.now(),
|
|
79
|
-
message_id: `input.${Date.now()}`,
|
|
80
|
-
message_seq: 0,
|
|
81
|
-
sender: {
|
|
82
|
-
uid: 'input',
|
|
83
|
-
uin: 'input',
|
|
84
|
-
nick: 'input',
|
|
85
|
-
role: "unknown" /* Role.Unknown */,
|
|
86
|
-
},
|
|
87
|
-
elements: [{ type: 'text', text: elements }],
|
|
88
|
-
contact: {
|
|
89
|
-
scene: "friend" /* Scene.Private */,
|
|
90
|
-
peer: 'input',
|
|
91
|
-
sub_peer: '',
|
|
92
|
-
},
|
|
93
|
-
raw_event: { data: elements },
|
|
94
|
-
};
|
|
95
|
-
const e = new KarinMessage(message);
|
|
96
|
-
e.bot = this;
|
|
97
|
-
e.replyCallback = async (elements) => {
|
|
98
|
-
this.SendMessage(e.contact, elements);
|
|
99
|
-
return { message_id: e.message_id, message_time: Date.now(), raw_data: elements };
|
|
100
|
-
};
|
|
101
|
-
listener.emit('adapter.message', e);
|
|
102
|
-
}
|
|
103
|
-
async #MsgToFile(type, file) {
|
|
104
|
-
if (!msgToFile)
|
|
105
|
-
return '';
|
|
106
|
-
// 判断是否为string 如果是则继续判断是否为url、path
|
|
107
|
-
if (typeof file === 'string') {
|
|
108
|
-
if (file.startsWith('http'))
|
|
109
|
-
return file;
|
|
110
|
-
if (common.exists(file))
|
|
111
|
-
return file;
|
|
112
|
-
}
|
|
113
|
-
const buffer = await common.buffer(file);
|
|
114
|
-
// 生成文件名 根据type生成不同的文件后缀
|
|
115
|
-
const name = `${Date.now()}.${type === 'image' ? 'jpg' : type === 'record' ? 'mp3' : 'file'}`;
|
|
116
|
-
fs.writeFileSync(`./temp/input/${name}`, buffer);
|
|
117
|
-
return `[${type === 'image' ? '图片' : '语音'}: http://${ip}:${config.Server.http.port}/api/input?name=${name}&token=${this.token} ]`;
|
|
118
|
-
}
|
|
119
|
-
async GetVersion() {
|
|
120
|
-
const data = this.version;
|
|
121
|
-
delete data.name;
|
|
122
|
-
return data;
|
|
123
|
-
}
|
|
124
|
-
async SendMessage(_contact, elements) {
|
|
125
|
-
const text = [];
|
|
126
|
-
for (const v of elements) {
|
|
127
|
-
switch (v.type) {
|
|
128
|
-
case 'at':
|
|
129
|
-
text.push(`@${v.uid}`);
|
|
130
|
-
break;
|
|
131
|
-
case 'face':
|
|
132
|
-
text.push(`[表情:${v.id}]`);
|
|
133
|
-
break;
|
|
134
|
-
case 'text':
|
|
135
|
-
text.push(v.text);
|
|
136
|
-
break;
|
|
137
|
-
case 'image':
|
|
138
|
-
case 'record':
|
|
139
|
-
text.push(await this.#MsgToFile(v.type, v.file));
|
|
140
|
-
break;
|
|
141
|
-
default:
|
|
142
|
-
text.push(`[未知消息类型:${JSON.stringify(v)}]`);
|
|
143
|
-
}
|
|
144
|
-
}
|
|
145
|
-
this.logger('info', `${logger.green('Send private input: ')}${text.join('').replace(/\n/g, '\\n')}`);
|
|
146
|
-
return { message_id: 'input' };
|
|
147
|
-
}
|
|
148
|
-
getAvatarUrl() {
|
|
149
|
-
return 'https://p.qlogo.cn/gh/967068507/967068507/0';
|
|
150
|
-
}
|
|
151
|
-
getGroupAvatarUrl() {
|
|
152
|
-
return 'https://p.qlogo.cn/gh/967068507/967068507/0';
|
|
153
|
-
}
|
|
154
|
-
async GetCurrentAccount() {
|
|
155
|
-
return { account_uid: 'input', account_uin: 'input', account_name: 'input' };
|
|
156
|
-
}
|
|
157
|
-
GetEssenceMessageList() { throw new Error('Method not implemented.'); }
|
|
158
|
-
DownloadForwardMessage() { throw new Error('Method not implemented.'); }
|
|
159
|
-
SetEssenceMessage() { throw new Error('Method not implemented.'); }
|
|
160
|
-
DeleteEssenceMessage() { throw new Error('Method not implemented.'); }
|
|
161
|
-
SetFriendApplyResult() { throw new Error('Method not implemented.'); }
|
|
162
|
-
SetGroupApplyResult() { throw new Error('Method not implemented.'); }
|
|
163
|
-
SetInvitedJoinGroupResult() { throw new Error('Method not implemented.'); }
|
|
164
|
-
ReactMessageWithEmoji() { throw new Error('Method not implemented.'); }
|
|
165
|
-
UploadPrivateFile() { throw new Error('Method not implemented.'); }
|
|
166
|
-
UploadGroupFile() { throw new Error('Method not implemented.'); }
|
|
167
|
-
UploadForwardMessage() { throw new Error('Method not implemented.'); }
|
|
168
|
-
sendForwardMessage() { throw new Error('Method not implemented.'); }
|
|
169
|
-
SendMessageByResId() { throw new Error('Method not implemented.'); }
|
|
170
|
-
RecallMessage() { throw new Error('Method not implemented.'); }
|
|
171
|
-
GetMessage() { throw new Error('Method not implemented.'); }
|
|
172
|
-
GetHistoryMessage() { throw new Error('Method not implemented.'); }
|
|
173
|
-
VoteUser() { throw new Error('Method not implemented.'); }
|
|
174
|
-
KickMember() { throw new Error('Method not implemented.'); }
|
|
175
|
-
BanMember() { throw new Error('Method not implemented.'); }
|
|
176
|
-
SetGroupWholeBan() { throw new Error('Method not implemented.'); }
|
|
177
|
-
SetGroupAdmin() { throw new Error('Method not implemented.'); }
|
|
178
|
-
ModifyMemberCard() { throw new Error('Method not implemented.'); }
|
|
179
|
-
ModifyGroupName() { throw new Error('Method not implemented.'); }
|
|
180
|
-
LeaveGroup() { throw new Error('Method not implemented.'); }
|
|
181
|
-
SetGroupUniqueTitle() { throw new Error('Method not implemented.'); }
|
|
182
|
-
GetStrangerProfileCard() { throw new Error('Method not implemented.'); }
|
|
183
|
-
GetFriendList() { throw new Error('Method not implemented.'); }
|
|
184
|
-
GetGroupInfo() { throw new Error('Method not implemented.'); }
|
|
185
|
-
GetGroupList() { throw new Error('Method not implemented.'); }
|
|
186
|
-
GetGroupMemberInfo() { throw new Error('Method not implemented.'); }
|
|
187
|
-
GetGroupMemberList() { throw new Error('Method not implemented.'); }
|
|
188
|
-
GetGroupHonor() { throw new Error('Method not implemented.'); }
|
|
189
|
-
DownloadFile() { throw new Error('Method not implemented.'); }
|
|
190
|
-
CreateFolder() { throw new Error('Method not implemented.'); }
|
|
191
|
-
RenameFolder() { throw new Error('Method not implemented.'); }
|
|
192
|
-
DeleteFolde() { throw new Error('Method not implemented.'); }
|
|
193
|
-
DeleteFolder() { throw new Error('Method not implemented.'); }
|
|
194
|
-
UploadFile() { throw new Error('Method not implemented.'); }
|
|
195
|
-
DeleteFile() { throw new Error('Method not implemented.'); }
|
|
196
|
-
GetFileSystemInfo() { throw new Error('Method not implemented.'); }
|
|
197
|
-
GetFileList() { throw new Error('Method not implemented.'); }
|
|
198
|
-
ModifyGroupRemark() { throw new Error('Method not implemented.'); }
|
|
199
|
-
GetRemainCountAtAll() { throw new Error('Method not implemented.'); }
|
|
200
|
-
GetProhibitedUserList() { throw new Error('Method not implemented.'); }
|
|
201
|
-
PokeMember() { throw new Error('Method not implemented.'); }
|
|
202
|
-
SetMessageReaded() { throw new Error('Method not implemented.'); }
|
|
203
|
-
}
|
|
204
|
-
if (enable)
|
|
205
|
-
new AdapterInput().stdin().init();
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { AdapterOneBot11 } from './index.js';
|
|
2
|
-
import { KarinElement, OB11Segment } from '../../../types/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* onebot11转karin
|
|
5
|
-
* @return karin格式消息
|
|
6
|
-
*/
|
|
7
|
-
export declare function AdapterConvertKarin(data: Array<OB11Segment>): Array<KarinElement>;
|
|
8
|
-
/**
|
|
9
|
-
* karin转onebot11
|
|
10
|
-
* @param data karin格式消息
|
|
11
|
-
*/
|
|
12
|
-
export declare function KarinConvertAdapter(data: Array<KarinElement>, bot: AdapterOneBot11): Array<OB11Segment>;
|
|
@@ -1,167 +0,0 @@
|
|
|
1
|
-
import fs from 'fs';
|
|
2
|
-
import { segment } from '../../../utils/index.js';
|
|
3
|
-
/**
|
|
4
|
-
* onebot11转karin
|
|
5
|
-
* @return karin格式消息
|
|
6
|
-
*/
|
|
7
|
-
export function AdapterConvertKarin(data) {
|
|
8
|
-
const elements = [];
|
|
9
|
-
for (const i of data) {
|
|
10
|
-
switch (i.type) {
|
|
11
|
-
case 'text':
|
|
12
|
-
elements.push(segment.text(i.data.text));
|
|
13
|
-
break;
|
|
14
|
-
case 'face':
|
|
15
|
-
elements.push(segment.face(Number(i.data.id)));
|
|
16
|
-
break;
|
|
17
|
-
case 'image':
|
|
18
|
-
elements.push(segment.image(i.data.url || i.data.file, { file_type: i.data.type }));
|
|
19
|
-
break;
|
|
20
|
-
case 'record':
|
|
21
|
-
elements.push(segment.record(i.data.url || i.data.file, i.data.magic === 1));
|
|
22
|
-
break;
|
|
23
|
-
case 'video':
|
|
24
|
-
elements.push(segment.video(i.data.url || i.data.file));
|
|
25
|
-
break;
|
|
26
|
-
case 'at':
|
|
27
|
-
elements.push(segment.at(i.data.qq, i.data.qq, i.data.name));
|
|
28
|
-
break;
|
|
29
|
-
case 'poke':
|
|
30
|
-
elements.push(segment.poke(Number(i.data.id), Number(i.data.type)));
|
|
31
|
-
break;
|
|
32
|
-
case 'contact':
|
|
33
|
-
elements.push(segment.contact(i.data.type === 'qq' ? 'friend' : 'group', i.data.id));
|
|
34
|
-
break;
|
|
35
|
-
case 'location':
|
|
36
|
-
elements.push(segment.location(Number(i.data.lat), Number(i.data.lon), i.data.title || '', i.data.content || ''));
|
|
37
|
-
break;
|
|
38
|
-
case 'reply':
|
|
39
|
-
elements.push(segment.reply(i.data.id));
|
|
40
|
-
break;
|
|
41
|
-
case 'forward':
|
|
42
|
-
elements.push(segment.forward(i.data.id));
|
|
43
|
-
break;
|
|
44
|
-
case 'json':
|
|
45
|
-
elements.push(segment.json(i.data.data));
|
|
46
|
-
break;
|
|
47
|
-
case 'xml':
|
|
48
|
-
elements.push(segment.xml(i.data.data));
|
|
49
|
-
break;
|
|
50
|
-
default: {
|
|
51
|
-
elements.push(segment.text(JSON.stringify(i)));
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
return elements;
|
|
56
|
-
}
|
|
57
|
-
/**
|
|
58
|
-
* 处理非本地ws的文件
|
|
59
|
-
* @param file 文件路径
|
|
60
|
-
*/
|
|
61
|
-
function fileToBase64(file, bot) {
|
|
62
|
-
if (!bot || !file.startsWith('file://') || !bot.adapter.connect)
|
|
63
|
-
return file;
|
|
64
|
-
const list = ['127.0.0.1', 'localhost'];
|
|
65
|
-
const url = new URL(bot.adapter.connect);
|
|
66
|
-
return list.includes(url.hostname) ? file : `base64://${fs.readFileSync(file.replace('file://', '')).toString('base64')}`;
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* karin转onebot11
|
|
70
|
-
* @param data karin格式消息
|
|
71
|
-
*/
|
|
72
|
-
export function KarinConvertAdapter(data, bot) {
|
|
73
|
-
const elements = [];
|
|
74
|
-
for (const i of data) {
|
|
75
|
-
const type = i.type;
|
|
76
|
-
switch (i.type) {
|
|
77
|
-
case "text" /* OB11SegmentType.Text */:
|
|
78
|
-
elements.push({ type, data: { text: i.text } });
|
|
79
|
-
break;
|
|
80
|
-
case "face" /* OB11SegmentType.Face */:
|
|
81
|
-
elements.push({ type, data: { id: i.id } });
|
|
82
|
-
break;
|
|
83
|
-
case "at" /* OB11SegmentType.At */:
|
|
84
|
-
elements.push({ type, data: { qq: String(i.uid || i.uin), name: i.name } });
|
|
85
|
-
break;
|
|
86
|
-
case "reply" /* OB11SegmentType.Reply */:
|
|
87
|
-
elements.push({ type, data: { id: i.message_id } });
|
|
88
|
-
break;
|
|
89
|
-
case "image" /* OB11SegmentType.Image */:
|
|
90
|
-
case "video" /* OB11SegmentType.Video */:
|
|
91
|
-
case "file" /* OB11SegmentType.File */: {
|
|
92
|
-
elements.push({ type, data: { file: fileToBase64(i.file, bot) } });
|
|
93
|
-
break;
|
|
94
|
-
}
|
|
95
|
-
case "xml" /* OB11SegmentType.Xml */: {
|
|
96
|
-
elements.push({ type, data: { data: i.data } });
|
|
97
|
-
break;
|
|
98
|
-
}
|
|
99
|
-
case "json" /* OB11SegmentType.Json */: {
|
|
100
|
-
elements.push({ type, data: { data: i.data } });
|
|
101
|
-
break;
|
|
102
|
-
}
|
|
103
|
-
case "forward" /* OB11SegmentType.Forward */: {
|
|
104
|
-
elements.push({ type, data: { id: i.res_id } });
|
|
105
|
-
break;
|
|
106
|
-
}
|
|
107
|
-
case "record" /* OB11SegmentType.Record */: {
|
|
108
|
-
elements.push({ type, data: { file: fileToBase64(i.file, bot), magic: i.magic || false } });
|
|
109
|
-
break;
|
|
110
|
-
}
|
|
111
|
-
case "music" /* OB11SegmentType.Music */: {
|
|
112
|
-
if (i.id) {
|
|
113
|
-
elements.push({ type: 'music', data: { type: i.platform, id: i.id } });
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
const { url, audio, title, author, pic } = i;
|
|
117
|
-
elements.push({ type: 'music', data: { type: 'custom', url, audio, title, content: author, image: pic } });
|
|
118
|
-
}
|
|
119
|
-
break;
|
|
120
|
-
}
|
|
121
|
-
case "poke" /* OB11SegmentType.Poke */: {
|
|
122
|
-
elements.push({ type, data: { type: i.poke_type, id: i.id } });
|
|
123
|
-
break;
|
|
124
|
-
}
|
|
125
|
-
case 'bubble_face': {
|
|
126
|
-
elements.push({ type: 'bubble_face', data: { id: i.id, count: i.count } });
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
case "contact" /* OB11SegmentType.Contact */: {
|
|
130
|
-
elements.push({ type, data: { type: i.scene, id: i.peer } });
|
|
131
|
-
break;
|
|
132
|
-
}
|
|
133
|
-
case "location" /* OB11SegmentType.Location */: {
|
|
134
|
-
elements.push({ type, data: { lat: i.lat, lon: i.lon, title: i.title, content: i.address } });
|
|
135
|
-
break;
|
|
136
|
-
}
|
|
137
|
-
case 'long_msg':
|
|
138
|
-
case 'basketball':
|
|
139
|
-
case 'dice':
|
|
140
|
-
case 'market_face':
|
|
141
|
-
case 'rps': {
|
|
142
|
-
elements.push({ type: i.type, data: { id: i.id } });
|
|
143
|
-
break;
|
|
144
|
-
}
|
|
145
|
-
case 'gift': {
|
|
146
|
-
elements.push({ type: 'gift', data: { qq: i.qq, id: i.id } });
|
|
147
|
-
break;
|
|
148
|
-
}
|
|
149
|
-
case 'share': {
|
|
150
|
-
elements.push({ type: 'share', data: { url: i.url, title: i.title, content: i.content, image: i.image } });
|
|
151
|
-
break;
|
|
152
|
-
}
|
|
153
|
-
case 'weather': {
|
|
154
|
-
elements.push({ type: 'weather', data: { city: i.city, type: i.type } });
|
|
155
|
-
break;
|
|
156
|
-
}
|
|
157
|
-
case 'button':
|
|
158
|
-
case 'markdown':
|
|
159
|
-
case 'keyboard':
|
|
160
|
-
default: {
|
|
161
|
-
elements.push(i);
|
|
162
|
-
break;
|
|
163
|
-
}
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
return elements;
|
|
167
|
-
}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { AdapterOneBot11 } from './index.js';
|
|
2
|
-
import { OB11EventAll, OB11MessageEvent, OB11MetaEvent, OB11NoticeEvent, OB11RequestEvent } from '../../../types/index.js';
|
|
3
|
-
export declare class OB11Event {
|
|
4
|
-
adapter: AdapterOneBot11;
|
|
5
|
-
constructor(adapter: AdapterOneBot11);
|
|
6
|
-
/**
|
|
7
|
-
* 处理事件
|
|
8
|
-
* - @param data ob11相关标准数据
|
|
9
|
-
*/
|
|
10
|
-
event(data: OB11EventAll): void;
|
|
11
|
-
/**
|
|
12
|
-
* 元事件
|
|
13
|
-
*/
|
|
14
|
-
metaEvent(data: OB11MetaEvent): void;
|
|
15
|
-
/**
|
|
16
|
-
* 消息事件
|
|
17
|
-
*/
|
|
18
|
-
messageEvent(data: OB11MessageEvent): void;
|
|
19
|
-
/**
|
|
20
|
-
* 通知事件
|
|
21
|
-
*/
|
|
22
|
-
noticeEvent(data: OB11NoticeEvent): void;
|
|
23
|
-
/** 请求事件 */
|
|
24
|
-
requestEvent(data: OB11RequestEvent): void;
|
|
25
|
-
}
|