oicq-icalingua-plus-plus 1.23.1 → 1.23.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/index.d.ts +2 -0
- package/lib/client.js +3 -0
- package/lib/message/chat.js +75 -1
- package/package.json +2 -2
package/index.d.ts
CHANGED
|
@@ -933,6 +933,8 @@ export class Client extends EventEmitter {
|
|
|
933
933
|
/** 获取群资料(该方法一般用于刷新群资料缓存,从缓存中获取直接访问 this.gl.get(gid) 即可) */
|
|
934
934
|
getGroupInfo(group_id: number, no_cache?: boolean): Promise<Ret<GroupInfo>>;
|
|
935
935
|
|
|
936
|
+
/** 互联分享 */
|
|
937
|
+
sendJsonMsg(recv_id: number, json: string, group: boolean): Promise<Ret>;
|
|
936
938
|
/** 私聊 */
|
|
937
939
|
_sendPrivateMsg(user_id: number, message: Sendable, auto_escape?: boolean): Promise<Ret<{ message_id: string }>>;
|
|
938
940
|
sendFile(user_id: number, file: MediaFile, name?: string, process?: (percentage: string) => void): Promise<Ret<{ message_id: string }>>;
|
package/lib/client.js
CHANGED
|
@@ -349,6 +349,9 @@ class Client extends EventEmitter {
|
|
|
349
349
|
|
|
350
350
|
///////////////////////////////////////////////////
|
|
351
351
|
|
|
352
|
+
sendJsonMsg(recv_id, json, group) {
|
|
353
|
+
return this._useProtocol(chat.sendJsonMsg, [recv_id, json, group]);
|
|
354
|
+
}
|
|
352
355
|
_sendPrivateMsg(user_id, message = "", auto_escape = false) {
|
|
353
356
|
return this._useProtocol(chat.sendMsg, [user_id, message, auto_escape, 0]);
|
|
354
357
|
}
|
package/lib/message/chat.js
CHANGED
|
@@ -50,6 +50,80 @@ function sendMsg(target, message, escape, type) {
|
|
|
50
50
|
return builder.buildAndSend(message, escape);
|
|
51
51
|
}
|
|
52
52
|
|
|
53
|
+
function random(min, max) {
|
|
54
|
+
const range = max - min;
|
|
55
|
+
const random = Math.random();
|
|
56
|
+
const result = min + Math.round(random * range);
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/**
|
|
61
|
+
* @this {import("../ref").Client}
|
|
62
|
+
* @param {number} target
|
|
63
|
+
* @param {import("../ref").MessageElem[]|String} json
|
|
64
|
+
* @param {boolean} group
|
|
65
|
+
* @returns {import("../ref").ProtocolResponse}
|
|
66
|
+
*/
|
|
67
|
+
async function sendJsonMsg(target, json, group) {
|
|
68
|
+
[target] = common.uinAutoCheck(target);
|
|
69
|
+
let json_data = null;
|
|
70
|
+
try {
|
|
71
|
+
json_data = JSON.parse(json);
|
|
72
|
+
} catch (err) { }
|
|
73
|
+
if (!json_data)
|
|
74
|
+
throw new Error("JSON 格式错误");
|
|
75
|
+
delete json_data['extra'];
|
|
76
|
+
|
|
77
|
+
const client_info = {
|
|
78
|
+
appid: 100951776,
|
|
79
|
+
appname: 'tv.danmaku.bili',
|
|
80
|
+
appsign: '7194d531cbe7960a22007b9f6bdaa38b',
|
|
81
|
+
miniapp_appid: 1109937557
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
const body = {
|
|
85
|
+
1: client_info.appid,
|
|
86
|
+
2: 1,
|
|
87
|
+
3: 10,
|
|
88
|
+
5: {
|
|
89
|
+
1: 1,
|
|
90
|
+
2: "0.0.0",
|
|
91
|
+
3: client_info.appname,
|
|
92
|
+
4: client_info.appsign,
|
|
93
|
+
},
|
|
94
|
+
7: {
|
|
95
|
+
15: parseInt(`${new Date().getTime()}${random(100, 999)}`)
|
|
96
|
+
},
|
|
97
|
+
10: group ? 1 : 0,
|
|
98
|
+
11: target,
|
|
99
|
+
18: {
|
|
100
|
+
1: client_info.miniapp_appid,
|
|
101
|
+
2: {
|
|
102
|
+
14: 'pages',
|
|
103
|
+
},
|
|
104
|
+
3: 'url',
|
|
105
|
+
4: 'text',
|
|
106
|
+
5: 'text',
|
|
107
|
+
6: 'text',
|
|
108
|
+
10: JSON.stringify(json_data),
|
|
109
|
+
},
|
|
110
|
+
19: 0
|
|
111
|
+
};
|
|
112
|
+
const payload = await this.sendOidb("OidbSvc.0xb77_9", pb.encode(body));
|
|
113
|
+
const data = pb.decode(payload);
|
|
114
|
+
if (data[3] !== 0)
|
|
115
|
+
return { result: -1, emsg: data[4] };
|
|
116
|
+
return { result: 0 };
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/**
|
|
120
|
+
* 发送离线文件
|
|
121
|
+
* @this {import("../ref").Client}
|
|
122
|
+
* @param {string|Buffer} file 一个文件路径,或者一块Buffer
|
|
123
|
+
* @param {string} filename 对方看到的文件名(file为Buffer时,若留空则自动以md5命名)
|
|
124
|
+
* @param {function} callback 监控上传进度的回调函数,拥有一个"百分比进度"的参数
|
|
125
|
+
* @returns {import("../ref").ProtocolResponse}
|
|
126
|
+
*/
|
|
53
127
|
async function sendFile(user_id, file, filename, callback) {
|
|
54
128
|
let filesize, filemd5, filesha, filestream
|
|
55
129
|
if (file instanceof Uint8Array) {
|
|
@@ -392,5 +466,5 @@ async function preloadImages(files = []) {
|
|
|
392
466
|
module.exports = {
|
|
393
467
|
sendMsg, sendTempMsg, recallMsg, reportReaded,
|
|
394
468
|
getOneMsg, getMsgs, getForwardMsg,
|
|
395
|
-
preloadImages, sendFile
|
|
469
|
+
preloadImages, sendFile, sendJsonMsg
|
|
396
470
|
};
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "oicq-icalingua-plus-plus",
|
|
3
3
|
"app_name": "oicq-icalingua-plus-plus",
|
|
4
|
-
"version": "1.23.
|
|
5
|
-
"app_version": "1.23.
|
|
4
|
+
"version": "1.23.2",
|
|
5
|
+
"app_version": "1.23.2",
|
|
6
6
|
"upday": "2023/01/06",
|
|
7
7
|
"protocol_version": "v11",
|
|
8
8
|
"description": "oicq(https://github.com/takayama-lily/oicq) v1 for Icalingua++",
|