mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
refactor: simplify code
This commit is contained in:
parent
c089ebea99
commit
7af0d9e87b
@ -65,35 +65,22 @@ export class PacketOperationContext {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async UploadResources(msg: PacketMsg[], groupUin: number = 0) {
|
async UploadResources(msg: PacketMsg[], groupUin: number = 0) {
|
||||||
const reqList = [];
|
const chatType = groupUin ? ChatType.KCHATTYPEGROUP : ChatType.KCHATTYPEC2C;
|
||||||
for (const m of msg) {
|
const peerUid = groupUin ? String(groupUin) : this.context.napcore.basicInfo.uid;
|
||||||
for (const e of m.msg) {
|
const reqList = msg.flatMap(m =>
|
||||||
|
m.msg.map(e => {
|
||||||
if (e instanceof PacketMsgPicElement) {
|
if (e instanceof PacketMsgPicElement) {
|
||||||
reqList.push(this.context.highway.uploadImage({
|
return this.context.highway.uploadImage({ chatType, peerUid }, e);
|
||||||
chatType: groupUin ? ChatType.KCHATTYPEGROUP : ChatType.KCHATTYPEC2C,
|
} else if (e instanceof PacketMsgVideoElement) {
|
||||||
peerUid: groupUin ? String(groupUin) : this.context.napcore.basicInfo.uid
|
return this.context.highway.uploadVideo({ chatType, peerUid }, e);
|
||||||
}, e));
|
} else if (e instanceof PacketMsgPttElement) {
|
||||||
|
return this.context.highway.uploadPtt({ chatType, peerUid }, e);
|
||||||
|
} else if (e instanceof PacketMsgFileElement) {
|
||||||
|
return this.context.highway.uploadFile({ chatType, peerUid }, e);
|
||||||
}
|
}
|
||||||
if (e instanceof PacketMsgVideoElement) {
|
return null;
|
||||||
reqList.push(this.context.highway.uploadVideo({
|
}).filter(Boolean)
|
||||||
chatType: groupUin ? ChatType.KCHATTYPEGROUP : ChatType.KCHATTYPEC2C,
|
);
|
||||||
peerUid: groupUin ? String(groupUin) : this.context.napcore.basicInfo.uid
|
|
||||||
}, e));
|
|
||||||
}
|
|
||||||
if (e instanceof PacketMsgPttElement) {
|
|
||||||
reqList.push(this.context.highway.uploadPtt({
|
|
||||||
chatType: groupUin ? ChatType.KCHATTYPEGROUP : ChatType.KCHATTYPEC2C,
|
|
||||||
peerUid: groupUin ? String(groupUin) : this.context.napcore.basicInfo.uid
|
|
||||||
}, e));
|
|
||||||
}
|
|
||||||
if (e instanceof PacketMsgFileElement) {
|
|
||||||
reqList.push(this.context.highway.uploadFile({
|
|
||||||
chatType: groupUin ? ChatType.KCHATTYPEGROUP : ChatType.KCHATTYPEC2C,
|
|
||||||
peerUid: groupUin ? String(groupUin) : this.context.napcore.basicInfo.uid
|
|
||||||
}, e));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
const res = await Promise.allSettled(reqList);
|
const res = await Promise.allSettled(reqList);
|
||||||
this.context.logger.info(`上传资源${res.length}个,失败${res.filter(r => r.status === 'rejected').length}个`);
|
this.context.logger.info(`上传资源${res.length}个,失败${res.filter(r => r.status === 'rejected').length}个`);
|
||||||
res.forEach((result, index) => {
|
res.forEach((result, index) => {
|
||||||
|
@ -45,11 +45,17 @@ export class Sha1Stream {
|
|||||||
let e = this._state[4];
|
let e = this._state[4];
|
||||||
|
|
||||||
for (let i = 0; i < 80; i++) {
|
for (let i = 0; i < 80; i++) {
|
||||||
const [f, k] = (i < 20) ? [(b & c) | ((~b) & d), 0x5A827999] :
|
let temp;
|
||||||
(i < 40) ? [b ^ c ^ d, 0x6ED9EBA1] :
|
if (i < 20) {
|
||||||
(i < 60) ? [(b & c) | (b & d) | (c & d), 0x8F1BBCDC] :
|
temp = ((b & c) | (~b & d)) + 0x5A827999;
|
||||||
[b ^ c ^ d, 0xCA62C1D6];
|
} else if (i < 40) {
|
||||||
const temp = (this.rotateLeft(a, 5) + f + k + e + w[i]) >>> 0;
|
temp = (b ^ c ^ d) + 0x6ED9EBA1;
|
||||||
|
} else if (i < 60) {
|
||||||
|
temp = ((b & c) | (b & d) | (c & d)) + 0x8F1BBCDC;
|
||||||
|
} else {
|
||||||
|
temp = (b ^ c ^ d) + 0xCA62C1D6;
|
||||||
|
}
|
||||||
|
temp += ((this.rotateLeft(a, 5) + e + w[i]) >>> 0);
|
||||||
e = d;
|
e = d;
|
||||||
d = c;
|
d = c;
|
||||||
c = this.rotateLeft(b, 30) >>> 0;
|
c = this.rotateLeft(b, 30) >>> 0;
|
||||||
|
@ -290,7 +290,7 @@ export async function NCoreInitShell() {
|
|||||||
await initializeEngine(engine, basicInfoWrapper, dataPathGlobal, systemPlatform, systemVersion);
|
await initializeEngine(engine, basicInfoWrapper, dataPathGlobal, systemPlatform, systemVersion);
|
||||||
await initializeLoginService(loginService, basicInfoWrapper, dataPathGlobal, systemVersion, hostname);
|
await initializeLoginService(loginService, basicInfoWrapper, dataPathGlobal, systemVersion, hostname);
|
||||||
|
|
||||||
let quickLoginUin = cmdOptions.qq;
|
const quickLoginUin = cmdOptions.qq;
|
||||||
const historyLoginList = (await loginService.getLoginList()).LocalLoginInfoList;
|
const historyLoginList = (await loginService.getLoginList()).LocalLoginInfoList;
|
||||||
|
|
||||||
const dataTimestape = new Date().getTime().toString();
|
const dataTimestape = new Date().getTime().toString();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user