fix: type

This commit is contained in:
手瓜一十雪 2024-11-14 13:19:50 +08:00
parent b7c95e53dc
commit 9aca98bf13
9 changed files with 17 additions and 17 deletions

View File

@ -5,17 +5,17 @@ import * as fs from 'fs';
import { CalculateStreamBytesTransform } from "@/core/packet/utils/crypto/sha1StreamBytesTransform"; import { CalculateStreamBytesTransform } from "@/core/packet/utils/crypto/sha1StreamBytesTransform";
function sha1Stream(readable: stream.Readable) { function sha1Stream(readable: stream.Readable) {
return new Promise((resolve, reject) => { return new Promise<Buffer>((resolve, reject) => {
readable.on('error', reject); readable.on('error', reject);
readable.pipe(crypto.createHash('sha1').on('error', reject).on('data', resolve)); readable.pipe(crypto.createHash('sha1').on('error', reject).on('data', resolve));
}) as Promise<Buffer>; });
} }
function md5Stream(readable: stream.Readable) { function md5Stream(readable: stream.Readable) {
return new Promise((resolve, reject) => { return new Promise<Buffer>((resolve, reject) => {
readable.on('error', reject); readable.on('error', reject);
readable.pipe(crypto.createHash('md5').on('error', reject).on('data', resolve)); readable.pipe(crypto.createHash('md5').on('error', reject).on('data', resolve));
}) as Promise<Buffer>; });
} }
export function calculateSha1(filePath: string): Promise<Buffer> { export function calculateSha1(filePath: string): Promise<Buffer> {

View File

@ -29,7 +29,7 @@ abstract class BaseAction<PayloadType, ReturnDataType> {
}); });
return { return {
valid: false, valid: false,
message: errorMessages.join('\n') as string || '未知错误', message: errorMessages.join('\n') ?? '未知错误',
}; };
} }
return { return {

View File

@ -60,7 +60,7 @@ export class GetMiniAppArk extends GetPacketStatusDepends<Payload, {
if (payload.type) { if (payload.type) {
reqParam = MiniAppInfoHelper.generateReq(customParams, MiniAppInfo.get(payload.type)!.template); reqParam = MiniAppInfoHelper.generateReq(customParams, MiniAppInfo.get(payload.type)!.template);
} else { } else {
const { appId, scene, iconUrl, templateType, businessType, verType, shareType, versionId, withShareTicket } = payload as Required<Payload>; const { appId, scene, iconUrl, templateType, businessType, verType, shareType, versionId, withShareTicket } = payload;
reqParam = MiniAppInfoHelper.generateReq( reqParam = MiniAppInfoHelper.generateReq(
customParams, customParams,
{ {

View File

@ -133,7 +133,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
guildId: '', guildId: '',
peerUid: peer.peerUid, peerUid: peer.peerUid,
chatType: peer.chatType, chatType: peer.chatType,
}, (returnMsgAndResId.message)!.msgId); }, (returnMsgAndResId.message).msgId);
return { message_id: msgShortId!, res_id: returnMsgAndResId.res_id }; return { message_id: msgShortId!, res_id: returnMsgAndResId.res_id };
} else if (returnMsgAndResId.res_id && !returnMsgAndResId.message) { } else if (returnMsgAndResId.res_id && !returnMsgAndResId.message) {
throw Error(`发送转发消息res_id${returnMsgAndResId.res_id} 失败`); throw Error(`发送转发消息res_id${returnMsgAndResId.res_id} 失败`);
@ -150,7 +150,7 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
const { sendElements, deleteAfterSentFiles } = await this.obContext.apis.MsgApi const { sendElements, deleteAfterSentFiles } = await this.obContext.apis.MsgApi
.createSendElements(messages, peer); .createSendElements(messages, peer);
const returnMsg = await this.obContext.apis.MsgApi.sendMsgWithOb11UniqueId(peer, sendElements, deleteAfterSentFiles); const returnMsg = await this.obContext.apis.MsgApi.sendMsgWithOb11UniqueId(peer, sendElements, deleteAfterSentFiles);
return { message_id: returnMsg!.id! }; return { message_id: returnMsg.id! };
} }
private async uploadForwardedNodesPacket(msgPeer: Peer, messageNodes: OB11MessageNode[], source?: string, news?: { private async uploadForwardedNodesPacket(msgPeer: Peer, messageNodes: OB11MessageNode[], source?: string, news?: {

View File

@ -165,10 +165,10 @@ export class OneBotGroupApi {
async parseGroupBanEvent(GroupCode: string, grayTipElement: GrayTipElement) { async parseGroupBanEvent(GroupCode: string, grayTipElement: GrayTipElement) {
const groupElement = grayTipElement?.groupElement; const groupElement = grayTipElement?.groupElement;
if (!groupElement?.shutUp) return undefined; if (!groupElement?.shutUp) return undefined;
const memberUid = groupElement.shutUp!.member.uid; const memberUid = groupElement.shutUp.member.uid;
const adminUid = groupElement.shutUp!.admin.uid; const adminUid = groupElement.shutUp.admin.uid;
let memberUin: string; let memberUin: string;
let duration = parseInt(groupElement.shutUp!.duration); let duration = parseInt(groupElement.shutUp.duration);
const subType: 'ban' | 'lift_ban' = duration > 0 ? 'ban' : 'lift_ban'; const subType: 'ban' | 'lift_ban' = duration > 0 ? 'ban' : 'lift_ban';
if (memberUid) { if (memberUid) {
memberUin = (await this.core.apis.GroupApi.getGroupMember(GroupCode, memberUid))?.uin ?? ''; memberUin = (await this.core.apis.GroupApi.getGroupMember(GroupCode, memberUid))?.uin ?? '';

View File

@ -700,7 +700,7 @@ export class OneBotMsgApi {
//跳过空消息 //跳过空消息
const resMsg: OB11Message = { const resMsg: OB11Message = {
self_id: parseInt(this.core.selfInfo.uin), self_id: parseInt(this.core.selfInfo.uin),
user_id: parseInt(msg.senderUin!), user_id: parseInt(msg.senderUin),
time: parseInt(msg.msgTime) || Date.now(), time: parseInt(msg.msgTime) || Date.now(),
message_id: msg.id!, message_id: msg.id!,
message_seq: msg.id!, message_seq: msg.id!,

View File

@ -25,7 +25,7 @@ export class OB11Entities {
user_id: parseInt(rawFriend.coreInfo.uin), user_id: parseInt(rawFriend.coreInfo.uin),
nickname: rawFriend.coreInfo.nick, nickname: rawFriend.coreInfo.nick,
remark: rawFriend.coreInfo.remark ?? rawFriend.coreInfo.nick, remark: rawFriend.coreInfo.remark ?? rawFriend.coreInfo.nick,
sex: this.sex(rawFriend.baseInfo.sex!), sex: this.sex(rawFriend.baseInfo.sex),
level: 0, level: 0,
})); }));
} }

View File

@ -1,7 +1,7 @@
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent'; import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
import { NapCatCore } from '@/core'; import { NapCatCore } from '@/core';
//输入状态事件 初步完成 Mlikio wa Todo 需要做一些过滤 //work: 输入状态事件 初步完成 Mlikiowa 需要做一些过滤
export class OB11InputStatusEvent extends OB11BaseNoticeEvent { export class OB11InputStatusEvent extends OB11BaseNoticeEvent {
notice_type = 'notify'; notice_type = 'notify';
sub_type = 'input_status'; sub_type = 'input_status';

View File

@ -327,7 +327,7 @@ export class NapCatOneBot11Adapter {
const requesterUin = await this.core.apis.UserApi.getUinByUidV2(req.friendUid); const requesterUin = await this.core.apis.UserApi.getUinByUidV2(req.friendUid);
await this.networkManager.emitEvent(new OB11FriendRequestEvent( await this.networkManager.emitEvent(new OB11FriendRequestEvent(
this.core, this.core,
parseInt(requesterUin!), +requesterUin,
req.extWords, req.extWords,
req.friendUid + '|' + req.reqTime, req.friendUid + '|' + req.reqTime,
)); ));
@ -391,7 +391,7 @@ export class NapCatOneBot11Adapter {
} }
} else if (notify.type == GroupNotifyMsgType.MEMBER_LEAVE_NOTIFY_ADMIN || notify.type == GroupNotifyMsgType.KICK_MEMBER_NOTIFY_ADMIN) { } else if (notify.type == GroupNotifyMsgType.MEMBER_LEAVE_NOTIFY_ADMIN || notify.type == GroupNotifyMsgType.KICK_MEMBER_NOTIFY_ADMIN) {
this.context.logger.logDebug('有成员退出通知', notify); this.context.logger.logDebug('有成员退出通知', notify);
const member1Uin = (await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid))!; const member1Uin = (await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid));
let operatorId = member1Uin; let operatorId = member1Uin;
let subType: GroupDecreaseSubType = 'leave'; let subType: GroupDecreaseSubType = 'leave';
if (notify.user2.uid) { if (notify.user2.uid) {
@ -417,7 +417,7 @@ export class NapCatOneBot11Adapter {
].includes(notify.type) && notify.status == GroupNotifyMsgStatus.KUNHANDLE) { ].includes(notify.type) && notify.status == GroupNotifyMsgStatus.KUNHANDLE) {
this.context.logger.logDebug('有加群请求'); this.context.logger.logDebug('有加群请求');
try { try {
let requestUin = (await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid))!; let requestUin = (await this.core.apis.UserApi.getUinByUidV2(notify.user1.uid));
if (isNaN(parseInt(requestUin))) { if (isNaN(parseInt(requestUin))) {
requestUin = (await this.core.apis.UserApi.getUserDetailInfo(notify.user1.uid)).uin; requestUin = (await this.core.apis.UserApi.getUserDetailInfo(notify.user1.uid)).uin;
} }