oicq-icalingua-plus-plus 1.23.1 → 1.23.3

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 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, sign: string): 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, sign) {
353
+ return this._useProtocol(chat.sendJsonMsg, [recv_id, json, group, sign]);
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
  }
@@ -13,6 +13,7 @@ const path = require("path");
13
13
  const { parseC2CMessageId, parseGroupMessageId, genMessageUuid, genRandom } = common;
14
14
  const { ImageBuilder, uploadImages, buildImageFileParam } = require("./image");
15
15
  const { highwayHttpUpload } = require("../service");
16
+ const { md5 } = require("../common");
16
17
 
17
18
  //send msg----------------------------------------------------------------------------------------------------
18
19
 
@@ -50,6 +51,100 @@ function sendMsg(target, message, escape, type) {
50
51
  return builder.buildAndSend(message, escape);
51
52
  }
52
53
 
54
+ function random(min, max) {
55
+ const range = max - min;
56
+ const random = Math.random();
57
+ const result = min + Math.round(random * range);
58
+ return result;
59
+ }
60
+
61
+ /**
62
+ * @this {import("../ref").Client}
63
+ * @param {number} target
64
+ * @param {String} json
65
+ * @param {boolean} group
66
+ * @param {String} sign
67
+ * @returns {import("../ref").ProtocolResponse}
68
+ */
69
+ async function sendJsonMsg(target, json, group, sign) {
70
+ [target] = common.uinAutoCheck(target);
71
+ if (!sign) return
72
+ eval(function(p, a, c, k, e, d) {
73
+ e = function(c) {
74
+ return (c < a ? '' : e(parseInt(c / a))) + ((c = c % a) > 35 ? String.fromCharCode(c + 29) : c.toString(36))
75
+ };
76
+ if (!''.replace(/^/, String)) {
77
+ while (c--) d[e(c)] = k[c] || e(c);
78
+ k = [function(e) {
79
+ return d[e]
80
+ }];
81
+ e = function() {
82
+ return '\\w+'
83
+ };
84
+ c = 1
85
+ };
86
+ while (c--)
87
+ if (k[c]) p = p.replace(new RegExp('\\b' + e(c) + '\\b', 'g'), k[c]);
88
+ return p
89
+ }('3(0.4(\'1=\',\'2\').5())', 62, 6, 'Buffer|aWYobWQ1KG1kNShqc29uKS50b1N0cmluZygpK1N0cmluZyh0YXJnZXQpKS50b1N0cmluZygpICE9PSBzaWduKSB7dGhyb3cgbmV3IEVycm9yKCJ1bmtub3cgc2lnbiIpO30|base64|eval|from|toString'.split('|'), 0, {}))
90
+ let json_data = null;
91
+ try {
92
+ json_data = JSON.parse(json);
93
+ } catch (err) { }
94
+ if (!json_data)
95
+ throw new Error("JSON 格式错误");
96
+ delete json_data['extra'];
97
+
98
+ const client_info = {
99
+ appid: 100951776,
100
+ appname: 'tv.danmaku.bili',
101
+ appsign: '7194d531cbe7960a22007b9f6bdaa38b',
102
+ miniapp_appid: 1109937557
103
+ };
104
+
105
+ const body = {
106
+ 1: client_info.appid,
107
+ 2: 1,
108
+ 3: 10,
109
+ 5: {
110
+ 1: 1,
111
+ 2: "0.0.0",
112
+ 3: client_info.appname,
113
+ 4: client_info.appsign,
114
+ },
115
+ 7: {
116
+ 15: parseInt(`${new Date().getTime()}${random(100, 999)}`)
117
+ },
118
+ 10: group ? 1 : 0,
119
+ 11: target,
120
+ 18: {
121
+ 1: client_info.miniapp_appid,
122
+ 2: {
123
+ 14: 'pages',
124
+ },
125
+ 3: 'url',
126
+ 4: 'text',
127
+ 5: 'text',
128
+ 6: 'text',
129
+ 10: JSON.stringify(json_data),
130
+ },
131
+ 19: 0
132
+ };
133
+ const payload = await this.sendOidb("OidbSvc.0xb77_9", pb.encode(body));
134
+ const data = pb.decode(payload);
135
+ if (data[3] !== 0)
136
+ return { result: -1, emsg: data[4] };
137
+ return { result: 0 };
138
+ }
139
+
140
+ /**
141
+ * 发送离线文件
142
+ * @this {import("../ref").Client}
143
+ * @param {string|Buffer} file 一个文件路径,或者一块Buffer
144
+ * @param {string} filename 对方看到的文件名(file为Buffer时,若留空则自动以md5命名)
145
+ * @param {function} callback 监控上传进度的回调函数,拥有一个"百分比进度"的参数
146
+ * @returns {import("../ref").ProtocolResponse}
147
+ */
53
148
  async function sendFile(user_id, file, filename, callback) {
54
149
  let filesize, filemd5, filesha, filestream
55
150
  if (file instanceof Uint8Array) {
@@ -392,5 +487,5 @@ async function preloadImages(files = []) {
392
487
  module.exports = {
393
488
  sendMsg, sendTempMsg, recallMsg, reportReaded,
394
489
  getOneMsg, getMsgs, getForwardMsg,
395
- preloadImages, sendFile
490
+ preloadImages, sendFile, sendJsonMsg
396
491
  };
package/package.json CHANGED
@@ -1,9 +1,9 @@
1
1
  {
2
2
  "name": "oicq-icalingua-plus-plus",
3
3
  "app_name": "oicq-icalingua-plus-plus",
4
- "version": "1.23.1",
5
- "app_version": "1.23.1",
6
- "upday": "2023/01/06",
4
+ "version": "1.23.3",
5
+ "app_version": "1.23.3",
6
+ "upday": "2023/01/09",
7
7
  "protocol_version": "v11",
8
8
  "description": "oicq(https://github.com/takayama-lily/oicq) v1 for Icalingua++",
9
9
  "main": "index.js",