mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
test: 被赞事件(未完成)
This commit is contained in:
parent
964014fc5c
commit
1e63a2a7e7
22
src/core/proto/ProfileLikeTip.proto
Normal file
22
src/core/proto/ProfileLikeTip.proto
Normal file
@ -0,0 +1,22 @@
|
||||
syntax = 'proto3';
|
||||
package SysMessage;
|
||||
|
||||
message ProfileLikeTip {
|
||||
ProfileLikeDetail profile_like_detail = 203;
|
||||
}
|
||||
|
||||
message ProfileLikeDetail {
|
||||
LikeDetail like_detail = 14;
|
||||
}
|
||||
|
||||
message LikeDetail {
|
||||
int32 times = 1;
|
||||
int32 time = 2;
|
||||
TextTip text_tip = 3;
|
||||
}
|
||||
|
||||
message TextTip {
|
||||
string txt = 1;
|
||||
int64 qq = 2;
|
||||
string nick = 3;
|
||||
}
|
281
src/core/proto/ProfileLikeTip.ts
Normal file
281
src/core/proto/ProfileLikeTip.ts
Normal file
@ -0,0 +1,281 @@
|
||||
// @generated by protobuf-ts 2.9.4
|
||||
// @generated from protobuf file "ProfileLikeTip.proto" (package "SysMessage", syntax proto3)
|
||||
// tslint:disable
|
||||
import type { BinaryWriteOptions } from "@protobuf-ts/runtime";
|
||||
import type { IBinaryWriter } from "@protobuf-ts/runtime";
|
||||
import { WireType } from "@protobuf-ts/runtime";
|
||||
import type { BinaryReadOptions } from "@protobuf-ts/runtime";
|
||||
import type { IBinaryReader } from "@protobuf-ts/runtime";
|
||||
import { UnknownFieldHandler } from "@protobuf-ts/runtime";
|
||||
import type { PartialMessage } from "@protobuf-ts/runtime";
|
||||
import { reflectionMergePartial } from "@protobuf-ts/runtime";
|
||||
import { MessageType } from "@protobuf-ts/runtime";
|
||||
/**
|
||||
* @generated from protobuf message SysMessage.ProfileLikeTip
|
||||
*/
|
||||
export interface ProfileLikeTip {
|
||||
/**
|
||||
* @generated from protobuf field: SysMessage.ProfileLikeDetail profile_like_detail = 203;
|
||||
*/
|
||||
profileLikeDetail?: ProfileLikeDetail;
|
||||
}
|
||||
/**
|
||||
* @generated from protobuf message SysMessage.ProfileLikeDetail
|
||||
*/
|
||||
export interface ProfileLikeDetail {
|
||||
/**
|
||||
* @generated from protobuf field: SysMessage.LikeDetail like_detail = 14;
|
||||
*/
|
||||
likeDetail?: LikeDetail;
|
||||
}
|
||||
/**
|
||||
* @generated from protobuf message SysMessage.LikeDetail
|
||||
*/
|
||||
export interface LikeDetail {
|
||||
/**
|
||||
* @generated from protobuf field: int32 times = 1;
|
||||
*/
|
||||
times: number;
|
||||
/**
|
||||
* @generated from protobuf field: int32 time = 2;
|
||||
*/
|
||||
time: number;
|
||||
/**
|
||||
* @generated from protobuf field: SysMessage.TextTip text_tip = 3;
|
||||
*/
|
||||
textTip?: TextTip;
|
||||
}
|
||||
/**
|
||||
* @generated from protobuf message SysMessage.TextTip
|
||||
*/
|
||||
export interface TextTip {
|
||||
/**
|
||||
* @generated from protobuf field: string txt = 1;
|
||||
*/
|
||||
txt: string;
|
||||
/**
|
||||
* @generated from protobuf field: int64 qq = 2;
|
||||
*/
|
||||
qq: bigint;
|
||||
/**
|
||||
* @generated from protobuf field: string nick = 3;
|
||||
*/
|
||||
nick: string;
|
||||
}
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class ProfileLikeTip$Type extends MessageType<ProfileLikeTip> {
|
||||
constructor() {
|
||||
super("SysMessage.ProfileLikeTip", [
|
||||
{ no: 203, name: "profile_like_detail", kind: "message", T: () => ProfileLikeDetail }
|
||||
]);
|
||||
}
|
||||
create(value?: PartialMessage<ProfileLikeTip>): ProfileLikeTip {
|
||||
const message = globalThis.Object.create((this.messagePrototype!));
|
||||
if (value !== undefined)
|
||||
reflectionMergePartial<ProfileLikeTip>(this, message, value);
|
||||
return message;
|
||||
}
|
||||
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: ProfileLikeTip): ProfileLikeTip {
|
||||
let message = target ?? this.create(), end = reader.pos + length;
|
||||
while (reader.pos < end) {
|
||||
let [fieldNo, wireType] = reader.tag();
|
||||
switch (fieldNo) {
|
||||
case /* SysMessage.ProfileLikeDetail profile_like_detail */ 203:
|
||||
message.profileLikeDetail = ProfileLikeDetail.internalBinaryRead(reader, reader.uint32(), options, message.profileLikeDetail);
|
||||
break;
|
||||
default:
|
||||
let u = options.readUnknownField;
|
||||
if (u === "throw")
|
||||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||
let d = reader.skip(wireType);
|
||||
if (u !== false)
|
||||
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
internalBinaryWrite(message: ProfileLikeTip, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||
/* SysMessage.ProfileLikeDetail profile_like_detail = 203; */
|
||||
if (message.profileLikeDetail)
|
||||
ProfileLikeDetail.internalBinaryWrite(message.profileLikeDetail, writer.tag(203, WireType.LengthDelimited).fork(), options).join();
|
||||
let u = options.writeUnknownFields;
|
||||
if (u !== false)
|
||||
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @generated MessageType for protobuf message SysMessage.ProfileLikeTip
|
||||
*/
|
||||
export const ProfileLikeTip = new ProfileLikeTip$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class ProfileLikeDetail$Type extends MessageType<ProfileLikeDetail> {
|
||||
constructor() {
|
||||
super("SysMessage.ProfileLikeDetail", [
|
||||
{ no: 14, name: "like_detail", kind: "message", T: () => LikeDetail }
|
||||
]);
|
||||
}
|
||||
create(value?: PartialMessage<ProfileLikeDetail>): ProfileLikeDetail {
|
||||
const message = globalThis.Object.create((this.messagePrototype!));
|
||||
if (value !== undefined)
|
||||
reflectionMergePartial<ProfileLikeDetail>(this, message, value);
|
||||
return message;
|
||||
}
|
||||
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: ProfileLikeDetail): ProfileLikeDetail {
|
||||
let message = target ?? this.create(), end = reader.pos + length;
|
||||
while (reader.pos < end) {
|
||||
let [fieldNo, wireType] = reader.tag();
|
||||
switch (fieldNo) {
|
||||
case /* SysMessage.LikeDetail like_detail */ 14:
|
||||
message.likeDetail = LikeDetail.internalBinaryRead(reader, reader.uint32(), options, message.likeDetail);
|
||||
break;
|
||||
default:
|
||||
let u = options.readUnknownField;
|
||||
if (u === "throw")
|
||||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||
let d = reader.skip(wireType);
|
||||
if (u !== false)
|
||||
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
internalBinaryWrite(message: ProfileLikeDetail, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||
/* SysMessage.LikeDetail like_detail = 14; */
|
||||
if (message.likeDetail)
|
||||
LikeDetail.internalBinaryWrite(message.likeDetail, writer.tag(14, WireType.LengthDelimited).fork(), options).join();
|
||||
let u = options.writeUnknownFields;
|
||||
if (u !== false)
|
||||
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @generated MessageType for protobuf message SysMessage.ProfileLikeDetail
|
||||
*/
|
||||
export const ProfileLikeDetail = new ProfileLikeDetail$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class LikeDetail$Type extends MessageType<LikeDetail> {
|
||||
constructor() {
|
||||
super("SysMessage.LikeDetail", [
|
||||
{ no: 1, name: "times", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
|
||||
{ no: 2, name: "time", kind: "scalar", T: 5 /*ScalarType.INT32*/ },
|
||||
{ no: 3, name: "text_tip", kind: "message", T: () => TextTip }
|
||||
]);
|
||||
}
|
||||
create(value?: PartialMessage<LikeDetail>): LikeDetail {
|
||||
const message = globalThis.Object.create((this.messagePrototype!));
|
||||
message.times = 0;
|
||||
message.time = 0;
|
||||
if (value !== undefined)
|
||||
reflectionMergePartial<LikeDetail>(this, message, value);
|
||||
return message;
|
||||
}
|
||||
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: LikeDetail): LikeDetail {
|
||||
let message = target ?? this.create(), end = reader.pos + length;
|
||||
while (reader.pos < end) {
|
||||
let [fieldNo, wireType] = reader.tag();
|
||||
switch (fieldNo) {
|
||||
case /* int32 times */ 1:
|
||||
message.times = reader.int32();
|
||||
break;
|
||||
case /* int32 time */ 2:
|
||||
message.time = reader.int32();
|
||||
break;
|
||||
case /* SysMessage.TextTip text_tip */ 3:
|
||||
message.textTip = TextTip.internalBinaryRead(reader, reader.uint32(), options, message.textTip);
|
||||
break;
|
||||
default:
|
||||
let u = options.readUnknownField;
|
||||
if (u === "throw")
|
||||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||
let d = reader.skip(wireType);
|
||||
if (u !== false)
|
||||
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
internalBinaryWrite(message: LikeDetail, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||
/* int32 times = 1; */
|
||||
if (message.times !== 0)
|
||||
writer.tag(1, WireType.Varint).int32(message.times);
|
||||
/* int32 time = 2; */
|
||||
if (message.time !== 0)
|
||||
writer.tag(2, WireType.Varint).int32(message.time);
|
||||
/* SysMessage.TextTip text_tip = 3; */
|
||||
if (message.textTip)
|
||||
TextTip.internalBinaryWrite(message.textTip, writer.tag(3, WireType.LengthDelimited).fork(), options).join();
|
||||
let u = options.writeUnknownFields;
|
||||
if (u !== false)
|
||||
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @generated MessageType for protobuf message SysMessage.LikeDetail
|
||||
*/
|
||||
export const LikeDetail = new LikeDetail$Type();
|
||||
// @generated message type with reflection information, may provide speed optimized methods
|
||||
class TextTip$Type extends MessageType<TextTip> {
|
||||
constructor() {
|
||||
super("SysMessage.TextTip", [
|
||||
{ no: 1, name: "txt", kind: "scalar", T: 9 /*ScalarType.STRING*/ },
|
||||
{ no: 2, name: "qq", kind: "scalar", T: 3 /*ScalarType.INT64*/, L: 0 /*LongType.BIGINT*/ },
|
||||
{ no: 3, name: "nick", kind: "scalar", T: 9 /*ScalarType.STRING*/ }
|
||||
]);
|
||||
}
|
||||
create(value?: PartialMessage<TextTip>): TextTip {
|
||||
const message = globalThis.Object.create((this.messagePrototype!));
|
||||
message.txt = "";
|
||||
message.qq = 0n;
|
||||
message.nick = "";
|
||||
if (value !== undefined)
|
||||
reflectionMergePartial<TextTip>(this, message, value);
|
||||
return message;
|
||||
}
|
||||
internalBinaryRead(reader: IBinaryReader, length: number, options: BinaryReadOptions, target?: TextTip): TextTip {
|
||||
let message = target ?? this.create(), end = reader.pos + length;
|
||||
while (reader.pos < end) {
|
||||
let [fieldNo, wireType] = reader.tag();
|
||||
switch (fieldNo) {
|
||||
case /* string txt */ 1:
|
||||
message.txt = reader.string();
|
||||
break;
|
||||
case /* int64 qq */ 2:
|
||||
message.qq = reader.int64().toBigInt();
|
||||
break;
|
||||
case /* string nick */ 3:
|
||||
message.nick = reader.string();
|
||||
break;
|
||||
default:
|
||||
let u = options.readUnknownField;
|
||||
if (u === "throw")
|
||||
throw new globalThis.Error(`Unknown field ${fieldNo} (wire type ${wireType}) for ${this.typeName}`);
|
||||
let d = reader.skip(wireType);
|
||||
if (u !== false)
|
||||
(u === true ? UnknownFieldHandler.onRead : u)(this.typeName, message, fieldNo, wireType, d);
|
||||
}
|
||||
}
|
||||
return message;
|
||||
}
|
||||
internalBinaryWrite(message: TextTip, writer: IBinaryWriter, options: BinaryWriteOptions): IBinaryWriter {
|
||||
/* string txt = 1; */
|
||||
if (message.txt !== "")
|
||||
writer.tag(1, WireType.LengthDelimited).string(message.txt);
|
||||
/* int64 qq = 2; */
|
||||
if (message.qq !== 0n)
|
||||
writer.tag(2, WireType.Varint).int64(message.qq);
|
||||
/* string nick = 3; */
|
||||
if (message.nick !== "")
|
||||
writer.tag(3, WireType.LengthDelimited).string(message.nick);
|
||||
let u = options.writeUnknownFields;
|
||||
if (u !== false)
|
||||
(u == true ? UnknownFieldHandler.onWrite : u)(this.typeName, message, writer);
|
||||
return writer;
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @generated MessageType for protobuf message SysMessage.TextTip
|
||||
*/
|
||||
export const TextTip = new TextTip$Type();
|
@ -43,6 +43,10 @@ import { OB11FriendRecallNoticeEvent } from '@/onebot/event/notice/OB11FriendRec
|
||||
import { OB11GroupRecallNoticeEvent } from '@/onebot/event/notice/OB11GroupRecallNoticeEvent';
|
||||
import { LRUCache } from '@/common/lru-cache';
|
||||
import { NodeIKernelRecentContactListener } from '@/core/listeners/NodeIKernelRecentContactListener';
|
||||
import { SysMessage } from '@/core/proto/SysMessage';
|
||||
import { ProfileLikeTip } from '@/core/proto/ProfileLikeTip';
|
||||
import util from 'util';
|
||||
import { time } from 'console';
|
||||
|
||||
//OneBot实现类
|
||||
export class NapCatOneBot11Adapter {
|
||||
@ -238,35 +242,45 @@ export class NapCatOneBot11Adapter {
|
||||
private initMsgListener() {
|
||||
const msgListener = new NodeIKernelMsgListener();
|
||||
|
||||
/*
|
||||
msgListener.onRecvSysMsg = async () => {
|
||||
msgListener.onRecvSysMsg = async (msg) => {
|
||||
console.log('收到系统消息', util.inspect(msg, { depth: null, maxArrayLength: null }));
|
||||
const sysMsg = SysMessage.fromBinary(Uint8Array.from(msg));
|
||||
if (sysMsg.msgSpec.length === 0) {
|
||||
return;
|
||||
}
|
||||
console.log( '收到系统消息:Uint8Array:', util.inspect(Uint8Array.from(msg), { depth: null, maxArrayLength: null }));
|
||||
const { msgType, subType, subSubType } = sysMsg.msgSpec[0];
|
||||
if (msgType === 732 && subType === 16 && subSubType === 16) {
|
||||
const greyTip = GreyTipWrapper.fromBinary(Uint8Array.from(sysMsg.bodyWrapper!.wrappedBody.slice(7)));
|
||||
if (greyTip.subTypeId === 36) {
|
||||
const emojiLikeToOthers = EmojiLikeToOthersWrapper1
|
||||
.fromBinary(greyTip.rest)
|
||||
.wrapper!
|
||||
.body!;
|
||||
if (emojiLikeToOthers.attributes?.operation !== 1) { // Un-like
|
||||
return;
|
||||
}
|
||||
const eventOrEmpty = await this.apis.GroupApi.createGroupEmojiLikeEvent(
|
||||
greyTip.groupCode.toString(),
|
||||
await this.core.apis.UserApi.getUinByUidV2(emojiLikeToOthers.attributes!.senderUid),
|
||||
emojiLikeToOthers.msgSpec!.msgSeq.toString(),
|
||||
emojiLikeToOthers.attributes!.emojiId,
|
||||
);
|
||||
// eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||
eventOrEmpty && await this.networkManager.emitEvent(eventOrEmpty);
|
||||
this.core.context.logger.log('收到系统消息类型', msgType, subType, subSubType);
|
||||
if (msgType === 528 && subType === 39 && subSubType === 39) {
|
||||
console.log(util.inspect(sysMsg.bodyWrapper!.wrappedBody, { depth: null, maxArrayLength: null }));
|
||||
const profileLikeTip = ProfileLikeTip.fromBinary(Uint8Array.from(sysMsg.bodyWrapper!.wrappedBody));
|
||||
console.log("点赞提示: ", profileLikeTip);
|
||||
if (profileLikeTip.profileLikeDetail?.likeDetail) {
|
||||
const detail = profileLikeTip.profileLikeDetail.likeDetail.textTip;
|
||||
console.log("点赞详情: ", detail, "时间: ", Date.parse(profileLikeTip.profileLikeDetail.likeDetail.time.toString()));
|
||||
}
|
||||
}
|
||||
};
|
||||
// if (msgType === 732 && subType === 16 && subSubType === 16) {
|
||||
// const greyTip = GreyTipWrapper.fromBinary(Uint8Array.from(sysMsg.bodyWrapper!.wrappedBody.slice(7)));
|
||||
// if (greyTip.subTypeId === 36) {
|
||||
// const emojiLikeToOthers = EmojiLikeToOthersWrapper1
|
||||
// .fromBinary(greyTip.rest)
|
||||
// .wrapper!
|
||||
// .body!;
|
||||
// if (emojiLikeToOthers.attributes?.operation !== 1) { // Un-like
|
||||
// return;
|
||||
// }
|
||||
// const eventOrEmpty = await this.apis.GroupApi.createGroupEmojiLikeEvent(
|
||||
// greyTip.groupCode.toString(),
|
||||
// await this.core.apis.UserApi.getUinByUidV2(emojiLikeToOthers.attributes!.senderUid),
|
||||
// emojiLikeToOthers.msgSpec!.msgSeq.toString(),
|
||||
// emojiLikeToOthers.attributes!.emojiId,
|
||||
// );
|
||||
// // eslint-disable-next-line @typescript-eslint/no-unused-expressions
|
||||
// eventOrEmpty && await this.networkManager.emitEvent(eventOrEmpty);
|
||||
// }
|
||||
// }
|
||||
};
|
||||
*/
|
||||
|
||||
msgListener.onInputStatusPush = async data => {
|
||||
const uin = await this.core.apis.UserApi.getUinByUidV2(data.fromUin);
|
||||
|
Loading…
x
Reference in New Issue
Block a user