优化私聊戳一戳事件上报 (#643)

This commit is contained in:
凌莞~(=^▽^=)
2024-12-18 21:27:44 +08:00
committed by GitHub
parent 4be652ab33
commit f33df781bf
3 changed files with 11 additions and 8 deletions

View File

@@ -12,16 +12,17 @@ export class OneBotFriendApi {
}
//使用前预先判断 busiId 1061
async parsePrivatePokeEvent(grayTipElement: GrayTipElement) {
async parsePrivatePokeEvent(grayTipElement: GrayTipElement, uin: number) {
const json = JSON.parse(grayTipElement.jsonGrayTipElement.jsonStr);
let pokedetail: Array<{ uid: string }> = json.items;
const pokedetail: Array<{ uid: string }> = json.items;
//筛选item带有uid的元素
pokedetail = pokedetail.filter(item => item.uid);
if (pokedetail.length == 2) {
const poke_uid = pokedetail.filter(item => item.uid);
if (poke_uid.length == 2) {
return new OB11FriendPokeEvent(
this.core,
parseInt((await this.core.apis.UserApi.getUinByUidV2(pokedetail[0].uid))),
parseInt((await this.core.apis.UserApi.getUinByUidV2(pokedetail[1].uid))),
uin,
parseInt((await this.core.apis.UserApi.getUinByUidV2(poke_uid[0].uid))),
parseInt((await this.core.apis.UserApi.getUinByUidV2(poke_uid[1].uid))),
pokedetail,
);
}

View File

@@ -679,7 +679,7 @@ export class OneBotMsgApi {
async parsePrivateMsgEvent(msg: RawMessage, grayTipElement: GrayTipElement) {
if (grayTipElement.subElementType == NTGrayTipElementSubTypeV2.GRAYTIP_ELEMENT_SUBTYPE_JSON) {
if (grayTipElement.jsonGrayTipElement.busiId == 1061) {
const PokeEvent = await this.obContext.apis.FriendApi.parsePrivatePokeEvent(grayTipElement);
const PokeEvent = await this.obContext.apis.FriendApi.parsePrivatePokeEvent(grayTipElement, Number(await this.core.apis.UserApi.getUinByUidV2(msg.peerUid)));
if (PokeEvent) { return PokeEvent; };
} else if (grayTipElement.jsonGrayTipElement.busiId == 19324 && msg.peerUid !== '') {
return new OB11FriendAddNoticeEvent(this.core, Number(await this.core.apis.UserApi.getUinByUidV2(msg.peerUid)));