@alemonjs/onebot 0.0.1 → 0.0.2

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 CHANGED
@@ -127,7 +127,7 @@ var INDEXV11 = defineBot(() => {
127
127
  {
128
128
  type: 'image',
129
129
  data: {
130
- file_id: `base64://${item.toString('base64')}`
130
+ file: `base64://${item.toString('base64')}`
131
131
  }
132
132
  }
133
133
  ]
package/lib/index-12.js CHANGED
@@ -125,25 +125,31 @@ var INDEXV12 = defineBot(() => {
125
125
  return Promise.all([]);
126
126
  const content = useParse(val, 'Text');
127
127
  if (content) {
128
- return Promise.all([content].map(item => client.postMessage(event.ChannelId, [
129
- {
130
- type: 'text',
131
- data: {
132
- text: item
128
+ return Promise.all([content].map(item => client.sendGroupMsg({
129
+ group_id: event.ChannelId,
130
+ message: [
131
+ {
132
+ type: 'text',
133
+ data: {
134
+ text: item
135
+ }
133
136
  }
134
- }
135
- ])));
137
+ ]
138
+ })));
136
139
  }
137
140
  const images = useParse(val, 'Image');
138
141
  if (images) {
139
- return Promise.all(images.map(item => client.postMessage(event.ChannelId, [
140
- {
141
- type: 'image',
142
- data: {
143
- file_id: `base64://${item.toString('base64')}`
142
+ return Promise.all(images.map(item => client.sendGroupMsg({
143
+ group_id: event.ChannelId,
144
+ message: [
145
+ {
146
+ type: 'image',
147
+ data: {
148
+ file_id: item
149
+ }
144
150
  }
145
- }
146
- ])));
151
+ ]
152
+ })));
147
153
  }
148
154
  return Promise.all([]);
149
155
  }
@@ -96,17 +96,24 @@ class OneBotClient {
96
96
  }
97
97
  /**
98
98
  *
99
- * @param guild_id
100
- * @param message
99
+ * @param options
101
100
  * @returns
102
101
  */
103
- postMessage(guild_id, message) {
102
+ sendGroupMsg(options) {
104
103
  return this.#ws.send(JSON.stringify({
105
104
  action: 'send_group_msg',
106
- params: {
107
- group_id: guild_id,
108
- message: message
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,6 +1,6 @@
1
1
  {
2
2
  "name": "@alemonjs/onebot",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "onebot",
5
5
  "author": "lemonade",
6
6
  "license": "MIT",