@alemonjs/onebot 0.0.1 → 0.1.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/lib/index-11.js +13 -4
- package/lib/index-12.js +32 -17
- package/lib/sdk-v12/wss.js +14 -7
- package/package.json +3 -6
package/lib/index-11.js
CHANGED
|
@@ -48,6 +48,9 @@ var INDEXV11 = defineBot(() => {
|
|
|
48
48
|
IsMaster: uis.includes(String(event.user_id)),
|
|
49
49
|
// 用户ID
|
|
50
50
|
UserId: String(event.user_id),
|
|
51
|
+
GuildIdName: '',
|
|
52
|
+
GuildIdAvatar: '',
|
|
53
|
+
ChannelName: '',
|
|
51
54
|
// 用户名
|
|
52
55
|
UserName: event.sender.nickname,
|
|
53
56
|
// 用户头像
|
|
@@ -55,7 +58,7 @@ var INDEXV11 = defineBot(() => {
|
|
|
55
58
|
// 格式化数据
|
|
56
59
|
MsgId: String(event.message_id),
|
|
57
60
|
// 用户消息
|
|
58
|
-
|
|
61
|
+
MessageBody: [
|
|
59
62
|
Text(msg),
|
|
60
63
|
...at_users.map(item => At(item.id, 'user', {
|
|
61
64
|
name: item.name,
|
|
@@ -63,6 +66,8 @@ var INDEXV11 = defineBot(() => {
|
|
|
63
66
|
bot: item.bot
|
|
64
67
|
}))
|
|
65
68
|
],
|
|
69
|
+
MessageText: msg,
|
|
70
|
+
// 用户openId
|
|
66
71
|
// 用户openId
|
|
67
72
|
OpenID: String(event.user_id),
|
|
68
73
|
// 创建时间
|
|
@@ -105,7 +110,9 @@ var INDEXV11 = defineBot(() => {
|
|
|
105
110
|
send: (event, val) => {
|
|
106
111
|
if (val.length < 0)
|
|
107
112
|
return Promise.all([]);
|
|
108
|
-
const content = useParse(
|
|
113
|
+
const content = useParse({
|
|
114
|
+
MessageBody: val
|
|
115
|
+
}, 'Text');
|
|
109
116
|
if (content) {
|
|
110
117
|
return Promise.all([content].map(item => client.sendGroupMsg({
|
|
111
118
|
group_id: event.ChannelId,
|
|
@@ -119,7 +126,9 @@ var INDEXV11 = defineBot(() => {
|
|
|
119
126
|
]
|
|
120
127
|
})));
|
|
121
128
|
}
|
|
122
|
-
const images = useParse(
|
|
129
|
+
const images = useParse({
|
|
130
|
+
MessageBody: val
|
|
131
|
+
}, 'Image');
|
|
123
132
|
if (images) {
|
|
124
133
|
return Promise.all(images.map(item => client.sendGroupMsg({
|
|
125
134
|
group_id: event.ChannelId,
|
|
@@ -127,7 +136,7 @@ var INDEXV11 = defineBot(() => {
|
|
|
127
136
|
{
|
|
128
137
|
type: 'image',
|
|
129
138
|
data: {
|
|
130
|
-
|
|
139
|
+
file: `base64://${item.toString('base64')}`
|
|
131
140
|
}
|
|
132
141
|
}
|
|
133
142
|
]
|
package/lib/index-12.js
CHANGED
|
@@ -68,12 +68,15 @@ var INDEXV12 = defineBot(() => {
|
|
|
68
68
|
UserId: event.user_id,
|
|
69
69
|
// 用户名
|
|
70
70
|
UserName: event.sender.nickname,
|
|
71
|
+
GuildIdName: '',
|
|
72
|
+
GuildIdAvatar: '',
|
|
73
|
+
ChannelName: '',
|
|
71
74
|
// 用户头像
|
|
72
75
|
UserAvatar: event.platform == 'qq' ? `https://q1.qlogo.cn/g?b=qq&s=0&nk=${event.user_id}` : '',
|
|
73
76
|
// 格式化数据
|
|
74
77
|
MsgId: event.message_id,
|
|
75
78
|
// 用户消息
|
|
76
|
-
|
|
79
|
+
MessageBody: [
|
|
77
80
|
Text(msg),
|
|
78
81
|
...at_users.map(item => At(item.id, 'user', {
|
|
79
82
|
name: item.name,
|
|
@@ -81,6 +84,8 @@ var INDEXV12 = defineBot(() => {
|
|
|
81
84
|
bot: item.bot
|
|
82
85
|
}))
|
|
83
86
|
],
|
|
87
|
+
MessageText: msg,
|
|
88
|
+
// 表情
|
|
84
89
|
// 用户openId
|
|
85
90
|
OpenID: event.user_id,
|
|
86
91
|
//
|
|
@@ -123,27 +128,37 @@ var INDEXV12 = defineBot(() => {
|
|
|
123
128
|
send: (event, val) => {
|
|
124
129
|
if (val.length < 0)
|
|
125
130
|
return Promise.all([]);
|
|
126
|
-
const content = useParse(
|
|
131
|
+
const content = useParse({
|
|
132
|
+
MessageBody: val
|
|
133
|
+
}, 'Text');
|
|
127
134
|
if (content) {
|
|
128
|
-
return Promise.all([content].map(item => client.
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
135
|
+
return Promise.all([content].map(item => client.sendGroupMsg({
|
|
136
|
+
group_id: event.ChannelId,
|
|
137
|
+
message: [
|
|
138
|
+
{
|
|
139
|
+
type: 'text',
|
|
140
|
+
data: {
|
|
141
|
+
text: item
|
|
142
|
+
}
|
|
133
143
|
}
|
|
134
|
-
|
|
135
|
-
|
|
144
|
+
]
|
|
145
|
+
})));
|
|
136
146
|
}
|
|
137
|
-
const images = useParse(
|
|
147
|
+
const images = useParse({
|
|
148
|
+
MessageBody: val
|
|
149
|
+
}, 'Image');
|
|
138
150
|
if (images) {
|
|
139
|
-
return Promise.all(images.map(item => client.
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
151
|
+
return Promise.all(images.map(item => client.sendGroupMsg({
|
|
152
|
+
group_id: event.ChannelId,
|
|
153
|
+
message: [
|
|
154
|
+
{
|
|
155
|
+
type: 'image',
|
|
156
|
+
data: {
|
|
157
|
+
file_id: item
|
|
158
|
+
}
|
|
144
159
|
}
|
|
145
|
-
|
|
146
|
-
|
|
160
|
+
]
|
|
161
|
+
})));
|
|
147
162
|
}
|
|
148
163
|
return Promise.all([]);
|
|
149
164
|
}
|
package/lib/sdk-v12/wss.js
CHANGED
|
@@ -96,17 +96,24 @@ class OneBotClient {
|
|
|
96
96
|
}
|
|
97
97
|
/**
|
|
98
98
|
*
|
|
99
|
-
* @param
|
|
100
|
-
* @param message
|
|
99
|
+
* @param options
|
|
101
100
|
* @returns
|
|
102
101
|
*/
|
|
103
|
-
|
|
102
|
+
sendGroupMsg(options) {
|
|
104
103
|
return this.#ws.send(JSON.stringify({
|
|
105
104
|
action: 'send_group_msg',
|
|
106
|
-
params:
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
105
|
+
params: options,
|
|
106
|
+
echo: '1234'
|
|
107
|
+
}));
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* @param options
|
|
111
|
+
* @returns
|
|
112
|
+
*/
|
|
113
|
+
sendPrivateMsg(options) {
|
|
114
|
+
return this.#ws.send(JSON.stringify({
|
|
115
|
+
action: 'send_private_msg',
|
|
116
|
+
params: options,
|
|
110
117
|
echo: '1234'
|
|
111
118
|
}));
|
|
112
119
|
}
|
package/package.json
CHANGED
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alemonjs/onebot",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "onebot",
|
|
5
5
|
"author": "lemonade",
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"type": "module",
|
|
8
8
|
"main": "lib/index.js",
|
|
9
|
-
"dependencies": {
|
|
10
|
-
"chat-space": "^0.0.6"
|
|
11
|
-
},
|
|
12
9
|
"types": "lib",
|
|
13
10
|
"exports": {
|
|
14
11
|
".": {
|
|
@@ -26,9 +23,9 @@
|
|
|
26
23
|
"registry": "https://registry.npmjs.org",
|
|
27
24
|
"access": "public"
|
|
28
25
|
},
|
|
29
|
-
"bugs": "https://github.com/
|
|
26
|
+
"bugs": "https://github.com/lemonade-lab/alemonjs/issues",
|
|
30
27
|
"repository": {
|
|
31
28
|
"type": "git",
|
|
32
|
-
"url": "https://github.com/
|
|
29
|
+
"url": "https://github.com/lemonade-lab/alemonjs.git"
|
|
33
30
|
}
|
|
34
31
|
}
|