mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
refactor: poke
This commit is contained in:
parent
590b622e5f
commit
b1956d2a37
@ -43,7 +43,8 @@ import { deleteGroup, getGroupMember, groupMembers, selfInfo, tempGroupCodeMap }
|
||||
import { NTQQFileApi, NTQQGroupApi, NTQQMsgApi, NTQQUserApi } from '@/core/apis';
|
||||
import { OB11GroupMsgEmojiLikeEvent } from '@/onebot11/event/notice/OB11MsgEmojiLikeEvent';
|
||||
import { napCatCore } from '@/core';
|
||||
import { OB11GroupPokeEvent } from './event/notice/OB11PokeEvent';
|
||||
import { OB11FriendPokeEvent, OB11GroupPokeEvent } from './event/notice/OB11PokeEvent';
|
||||
import { OB11BaseNoticeEvent } from './event/notice/OB11BaseNoticeEvent';
|
||||
|
||||
|
||||
export class OB11Constructor {
|
||||
@ -286,7 +287,30 @@ export class OB11Constructor {
|
||||
resMsg.raw_message = resMsg.raw_message.trim();
|
||||
return resMsg;
|
||||
}
|
||||
|
||||
static async PrivateEvent(msg: RawMessage): Promise<OB11BaseNoticeEvent | undefined> {
|
||||
if (msg.chatType !== ChatType.friend) {
|
||||
return;
|
||||
}
|
||||
for (const element of msg.elements) {
|
||||
if (element.grayTipElement) {
|
||||
if (element.grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE) {
|
||||
const json = JSON.parse(element.grayTipElement.jsonGrayTipElement.jsonStr);
|
||||
if (element.grayTipElement.jsonGrayTipElement.busiId == 1061) {
|
||||
//判断业务类型
|
||||
//Poke事件
|
||||
let pokedetail: any[] = json.items;
|
||||
//筛选item带有uid的元素
|
||||
pokedetail = pokedetail.filter(item => item.uid);
|
||||
//console.log("[NapCat] 群拍一拍 群:", pokedetail, parseInt(msg.peerUid), " ", await NTQQUserApi.getUinByUid(pokedetail[0].uid), "拍了拍", await NTQQUserApi.getUinByUid(pokedetail[1].uid));
|
||||
if (pokedetail.length == 2) {
|
||||
return new OB11FriendPokeEvent(parseInt((await NTQQUserApi.getUinByUid(pokedetail[1].uid))!), parseInt((await NTQQUserApi.getUinByUid(pokedetail[0].uid))!));
|
||||
}
|
||||
}
|
||||
//下面得改 上面也是错的grayTipElement.subElementType == GrayTipElementSubType.MEMBER_NEW_TITLE
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
static async GroupEvent(msg: RawMessage): Promise<OB11GroupNoticeEvent | undefined> {
|
||||
//log("group msg", msg);
|
||||
if (msg.chatType !== ChatType.group) {
|
||||
|
@ -1,6 +1,6 @@
|
||||
import { OB11BaseNoticeEvent } from './OB11BaseNoticeEvent';
|
||||
|
||||
export abstract class OB11GroupNoticeEvent extends OB11BaseNoticeEvent {
|
||||
group_id: number;
|
||||
user_id: number;
|
||||
group_id: number = 0;
|
||||
user_id: number = 0;
|
||||
}
|
@ -48,7 +48,7 @@ export interface LineDevice {
|
||||
export let DeviceList = new Array<LineDevice>();
|
||||
|
||||
//peer->cached(boolen)
|
||||
const PokeCache = new Map<string, boolean>();
|
||||
// const PokeCache = new Map<string, boolean>();
|
||||
|
||||
export class NapCatOnebot11 {
|
||||
private bootTime: number = Date.now() / 1000; // 秒
|
||||
@ -121,20 +121,20 @@ export class NapCatOnebot11 {
|
||||
const MsgType = sysMsg.body[0].msgType;
|
||||
const subType0 = sysMsg.body[0].subType0;
|
||||
const subType1 = sysMsg.body[0].subType1;
|
||||
let pokeEvent: OB11FriendPokeEvent | OB11GroupPokeEvent;
|
||||
//console.log(peeruid);
|
||||
if (MsgType == 528 && subType0 == 290 && hex.length < 250 && hex.endsWith('04')) {
|
||||
// 防止上报两次 私聊戳一戳
|
||||
if (PokeCache.has(peeruid)) {
|
||||
//log('[私聊] 用户 ', peeruin, ' 对你戳一戳');
|
||||
pokeEvent = new OB11FriendPokeEvent(parseInt(selfInfo.uin), peeruin);
|
||||
postOB11Event(pokeEvent);
|
||||
}
|
||||
PokeCache.set(peeruid, false);
|
||||
setTimeout(() => {
|
||||
PokeCache.delete(peeruid);
|
||||
}, 1000);
|
||||
}
|
||||
// let pokeEvent: OB11FriendPokeEvent | OB11GroupPokeEvent;
|
||||
// //console.log(peeruid);
|
||||
// if (MsgType == 528 && subType0 == 290 && hex.length < 250 && hex.endsWith('04')) {
|
||||
// // 防止上报两次 私聊戳一戳
|
||||
// if (PokeCache.has(peeruid)) {
|
||||
// //log('[私聊] 用户 ', peeruin, ' 对你戳一戳');
|
||||
// pokeEvent = new OB11FriendPokeEvent(parseInt(selfInfo.uin), peeruin);
|
||||
// postOB11Event(pokeEvent);
|
||||
// }
|
||||
// PokeCache.set(peeruid, false);
|
||||
// setTimeout(() => {
|
||||
// PokeCache.delete(peeruid);
|
||||
// }, 1000);
|
||||
// }
|
||||
// if (MsgType == 732 && subType0 == 20 && hex.length < 150 && hex.endsWith('04')) {
|
||||
// // 防止上报两次 群聊戳一戳
|
||||
// if (PokeCache.has(peeruid)) {
|
||||
@ -331,12 +331,21 @@ export class NapCatOnebot11 {
|
||||
postOB11Event(msg);
|
||||
// log("post msg", msg)
|
||||
}).catch(e => logError('constructMessage error: ', e));
|
||||
|
||||
OB11Constructor.GroupEvent(message).then(groupEvent => {
|
||||
if (groupEvent) {
|
||||
// log("post group event", groupEvent);
|
||||
postOB11Event(groupEvent);
|
||||
}
|
||||
}).catch(e => logError('constructGroupEvent error: ', e));
|
||||
|
||||
OB11Constructor.PrivateEvent(message).then(privateEvent => {
|
||||
if (privateEvent) {
|
||||
// log("post private event", privateEvent);
|
||||
postOB11Event(privateEvent);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
async SetConfig(NewOb11: OB11Config) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user