mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
chore: code
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
import { NapCatCore } from '@/core';
|
import { NapCatCore } from '@/core';
|
||||||
|
import { profileLikeTip, ProfileLikeTipType } from '@/core/proto/ProfileLike';
|
||||||
|
|
||||||
import { NapCatOneBot11Adapter } from '@/onebot';
|
import { NapCatOneBot11Adapter } from '@/onebot';
|
||||||
|
import { OB11ProfileLikeEvent } from '../event/notice/OB11ProfileLikeEvent';
|
||||||
|
|
||||||
export class OneBotUserApi {
|
export class OneBotUserApi {
|
||||||
obContext: NapCatOneBot11Adapter;
|
obContext: NapCatOneBot11Adapter;
|
||||||
@@ -10,4 +12,20 @@ export class OneBotUserApi {
|
|||||||
this.obContext = obContext;
|
this.obContext = obContext;
|
||||||
this.core = core;
|
this.core = core;
|
||||||
}
|
}
|
||||||
|
async parseLikeEvent(wrappedBody: Uint8Array): Promise<OB11ProfileLikeEvent | undefined> {
|
||||||
|
const likeTip = profileLikeTip.decode(Uint8Array.from(wrappedBody.slice(12))) as unknown as ProfileLikeTipType;
|
||||||
|
this.core.context.logger.logDebug("收到点赞通知消息");
|
||||||
|
const likeMsg = likeTip.msg;
|
||||||
|
if (!likeMsg) return;
|
||||||
|
const detail = likeMsg.detail;
|
||||||
|
if (!detail) return;
|
||||||
|
const times = detail.txt.match(/\d+/) ?? "0";
|
||||||
|
return new OB11ProfileLikeEvent(
|
||||||
|
this.core,
|
||||||
|
Number(detail.uin),
|
||||||
|
detail.nickname,
|
||||||
|
parseInt(times[0], 10),
|
||||||
|
likeMsg.time,
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@@ -44,9 +44,7 @@ import { OB11GroupRecallNoticeEvent } from '@/onebot/event/notice/OB11GroupRecal
|
|||||||
import { LRUCache } from '@/common/lru-cache';
|
import { LRUCache } from '@/common/lru-cache';
|
||||||
import { NodeIKernelRecentContactListener } from '@/core/listeners/NodeIKernelRecentContactListener';
|
import { NodeIKernelRecentContactListener } from '@/core/listeners/NodeIKernelRecentContactListener';
|
||||||
import { OB11ProfileLikeEvent } from './event/notice/OB11ProfileLikeEvent';
|
import { OB11ProfileLikeEvent } from './event/notice/OB11ProfileLikeEvent';
|
||||||
import { profileLikeTip, ProfileLikeTipType, SysMessage, SysMessageMsgSpecType, SysMessageType } from '@/core/proto/ProfileLike';
|
import { profileLikeTip, ProfileLikeTipType, SysMessage, SysMessageType } from '@/core/proto/ProfileLike';
|
||||||
import { Message } from 'protobufjs';
|
|
||||||
|
|
||||||
//OneBot实现类
|
//OneBot实现类
|
||||||
export class NapCatOneBot11Adapter {
|
export class NapCatOneBot11Adapter {
|
||||||
readonly core: NapCatCore;
|
readonly core: NapCatCore;
|
||||||
@@ -247,20 +245,9 @@ export class NapCatOneBot11Adapter {
|
|||||||
}
|
}
|
||||||
const { msgType, subType, subSubType } = sysMsg.msgSpec[0];
|
const { msgType, subType, subSubType } = sysMsg.msgSpec[0];
|
||||||
if (msgType === 528 && subType === 39 && subSubType === 39) {
|
if (msgType === 528 && subType === 39 && subSubType === 39) {
|
||||||
const likeTip = profileLikeTip.decode(Uint8Array.from(sysMsg.bodyWrapper.wrappedBody.slice(12))) as unknown as ProfileLikeTipType;
|
if (!sysMsg.bodyWrapper) return;
|
||||||
this.core.context.logger.logDebug("收到点赞通知消息");
|
let event = await this.apis.UserApi.parseLikeEvent(sysMsg.bodyWrapper.wrappedBody);
|
||||||
const likeMsg = likeTip.msg;
|
if (event) await this.networkManager.emitEvent(event);
|
||||||
if (!likeMsg) return;
|
|
||||||
const detail = likeMsg.detail;
|
|
||||||
if (!detail) return;
|
|
||||||
const times = detail.txt.match(/\d+/) ?? "0";
|
|
||||||
await this.networkManager.emitEvent(new OB11ProfileLikeEvent(
|
|
||||||
this.core,
|
|
||||||
Number(detail.uin),
|
|
||||||
detail.nickname,
|
|
||||||
parseInt(times[0], 10),
|
|
||||||
likeMsg.time,
|
|
||||||
)).catch(e => this.context.logger.logError('处理被点赞事件失败', e));
|
|
||||||
};
|
};
|
||||||
/*
|
/*
|
||||||
if (msgType === 732 && subType === 16 && subSubType === 16) {
|
if (msgType === 732 && subType === 16 && subSubType === 16) {
|
||||||
|
Reference in New Issue
Block a user