mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
feat: invite join group event
This commit is contained in:
parent
54179cb686
commit
f42727c8ad
@ -178,6 +178,7 @@ export interface SendVideoElement {
|
|||||||
elementId: "",
|
elementId: "",
|
||||||
videoElement: VideoElement
|
videoElement: VideoElement
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SendArkElement {
|
export interface SendArkElement {
|
||||||
elementType: ElementType.ARK,
|
elementType: ElementType.ARK,
|
||||||
elementId: "",
|
elementId: "",
|
||||||
@ -243,7 +244,12 @@ export interface PicElement {
|
|||||||
md5HexStr?: string;
|
md5HexStr?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export enum GrayTipElementSubType {
|
||||||
|
INVITE_NEW_MEMBER = 12,
|
||||||
|
}
|
||||||
|
|
||||||
export interface GrayTipElement {
|
export interface GrayTipElement {
|
||||||
|
subElementType: GrayTipElementSubType;
|
||||||
revokeElement: {
|
revokeElement: {
|
||||||
operatorRole: string;
|
operatorRole: string;
|
||||||
operatorUid: string;
|
operatorUid: string;
|
||||||
@ -253,7 +259,10 @@ export interface GrayTipElement {
|
|||||||
wording: string; // 自定义的撤回提示语
|
wording: string; // 自定义的撤回提示语
|
||||||
}
|
}
|
||||||
aioOpGrayTipElement: TipAioOpGrayTipElement,
|
aioOpGrayTipElement: TipAioOpGrayTipElement,
|
||||||
groupElement: TipGroupElement
|
groupElement: TipGroupElement,
|
||||||
|
xmlElement: {
|
||||||
|
content: string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface FaceElement {
|
export interface FaceElement {
|
||||||
@ -398,6 +407,7 @@ export enum GroupNotifyStatus {
|
|||||||
APPROVE = 2,
|
APPROVE = 2,
|
||||||
REJECT = 3
|
REJECT = 3
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface GroupNotify {
|
export interface GroupNotify {
|
||||||
time: number; // 自己添加的字段,时间戳,毫秒, 用于判断收到短时间内收到重复的notify
|
time: number; // 自己添加的字段,时间戳,毫秒, 用于判断收到短时间内收到重复的notify
|
||||||
seq: string, // 唯一标识符,转成数字再除以1000应该就是时间戳?
|
seq: string, // 唯一标识符,转成数字再除以1000应该就是时间戳?
|
||||||
|
@ -11,6 +11,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
AtType,
|
AtType,
|
||||||
ChatType,
|
ChatType,
|
||||||
|
GrayTipElementSubType,
|
||||||
Group,
|
Group,
|
||||||
GroupMember,
|
GroupMember,
|
||||||
IMAGE_HTTP_HOST,
|
IMAGE_HTTP_HOST,
|
||||||
@ -19,7 +20,7 @@ import {
|
|||||||
TipGroupElementType,
|
TipGroupElementType,
|
||||||
User
|
User
|
||||||
} from '../ntqqapi/types';
|
} from '../ntqqapi/types';
|
||||||
import {getFriend, getGroup, getGroupMember, selfInfo, tempGroupCodeMap} from '../common/data';
|
import {getFriend, getGroupMember, selfInfo, tempGroupCodeMap} from '../common/data';
|
||||||
import {getConfigUtil, log, sleep} from "../common/utils";
|
import {getConfigUtil, log, sleep} from "../common/utils";
|
||||||
import {NTQQApi} from "../ntqqapi/ntcall";
|
import {NTQQApi} from "../ntqqapi/ntcall";
|
||||||
import {EventType} from "./event/OB11BaseEvent";
|
import {EventType} from "./event/OB11BaseEvent";
|
||||||
@ -206,33 +207,6 @@ export class OB11Constructor {
|
|||||||
message_data["type"] = OB11MessageDataType.face;
|
message_data["type"] = OB11MessageDataType.face;
|
||||||
message_data["data"]["id"] = element.faceElement.faceIndex.toString();
|
message_data["data"]["id"] = element.faceElement.faceIndex.toString();
|
||||||
}
|
}
|
||||||
// todo: 解析入群grayTipElement
|
|
||||||
else if (element.grayTipElement?.aioOpGrayTipElement) {
|
|
||||||
log("收到 group gray tip 消息", element.grayTipElement.aioOpGrayTipElement)
|
|
||||||
}
|
|
||||||
// if (message_data.data.file) {
|
|
||||||
// let filePath: string = message_data.data.file;
|
|
||||||
// if (!enableLocalFile2Url) {
|
|
||||||
// message_data.data.file = "file://" + filePath
|
|
||||||
// } else { // 不使用本地路径
|
|
||||||
// const ignoreTypes = [OB11MessageDataType.file, OB11MessageDataType.video]
|
|
||||||
// if (!ignoreTypes.includes(message_data.type)) {
|
|
||||||
// if (message_data.data.url && !message_data.data.url.startsWith(IMAGE_HTTP_HOST + "/download")) {
|
|
||||||
// message_data.data.file = message_data.data.url
|
|
||||||
// } else {
|
|
||||||
// let { err, data } = await file2base64(filePath);
|
|
||||||
// if (err) {
|
|
||||||
// log("文件转base64失败", filePath, err)
|
|
||||||
// } else {
|
|
||||||
// message_data.data.file = "base64://" + data
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// } else {
|
|
||||||
// message_data.data.file = "file://" + filePath
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
if (message_data.type !== "unknown" && message_data.data) {
|
if (message_data.type !== "unknown" && message_data.data) {
|
||||||
const cqCode = encodeCQCode(message_data);
|
const cqCode = encodeCQCode(message_data);
|
||||||
if (messagePostFormat === 'string') {
|
if (messagePostFormat === 'string') {
|
||||||
@ -251,7 +225,8 @@ export class OB11Constructor {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
for (let element of msg.elements) {
|
for (let element of msg.elements) {
|
||||||
const groupElement = element.grayTipElement?.groupElement
|
const grayTipElement = element.grayTipElement
|
||||||
|
const groupElement = grayTipElement?.groupElement
|
||||||
if (groupElement) {
|
if (groupElement) {
|
||||||
// log("收到群提示消息", groupElement)
|
// log("收到群提示消息", groupElement)
|
||||||
if (groupElement.type == TipGroupElementType.memberIncrease) {
|
if (groupElement.type == TipGroupElementType.memberIncrease) {
|
||||||
@ -297,6 +272,27 @@ export class OB11Constructor {
|
|||||||
else if (element.fileElement){
|
else if (element.fileElement){
|
||||||
return new OB11GroupUploadNoticeEvent(parseInt(msg.peerUid), parseInt(msg.senderUin), {id: element.fileElement.fileName, name: element.fileElement.fileName, size: parseInt(element.fileElement.fileSize)})
|
return new OB11GroupUploadNoticeEvent(parseInt(msg.peerUid), parseInt(msg.senderUin), {id: element.fileElement.fileName, name: element.fileElement.fileName, size: parseInt(element.fileElement.fileSize)})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (grayTipElement) {
|
||||||
|
if (grayTipElement.subElementType == GrayTipElementSubType.INVITE_NEW_MEMBER){
|
||||||
|
log("收到新人被邀请进群消息", grayTipElement)
|
||||||
|
const xmlElement = grayTipElement.xmlElement
|
||||||
|
if (xmlElement?.content){
|
||||||
|
const regex = /jp="(\d+)"/g;
|
||||||
|
|
||||||
|
let matches = [];
|
||||||
|
let match = null
|
||||||
|
|
||||||
|
while ((match = regex.exec(xmlElement.content)) !== null) {
|
||||||
|
matches.push(match[1]);
|
||||||
|
}
|
||||||
|
if (matches.length === 2){
|
||||||
|
const [inviter, invitee] = matches;
|
||||||
|
return new OB11GroupIncreaseEvent(parseInt(msg.peerUid), parseInt(invitee), parseInt(inviter), "invite");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
import {OB11GroupNoticeEvent} from "./OB11GroupNoticeEvent";
|
import {OB11GroupNoticeEvent} from "./OB11GroupNoticeEvent";
|
||||||
|
|
||||||
|
type GroupIncreaseSubType = "approve" | "invite";
|
||||||
export class OB11GroupIncreaseEvent extends OB11GroupNoticeEvent {
|
export class OB11GroupIncreaseEvent extends OB11GroupNoticeEvent {
|
||||||
notice_type = "group_increase";
|
notice_type = "group_increase";
|
||||||
sub_type = "approve"; // TODO: 实现其他几种子类型的识别 ("approve" | "invite")
|
|
||||||
operator_id: number;
|
operator_id: number;
|
||||||
|
sub_type: GroupIncreaseSubType;
|
||||||
constructor(groupId: number, userId: number, operatorId: number) {
|
constructor(groupId: number, userId: number, operatorId: number, subType: GroupIncreaseSubType = "approve") {
|
||||||
super();
|
super();
|
||||||
this.group_id = groupId;
|
this.group_id = groupId;
|
||||||
this.operator_id = operatorId;
|
this.operator_id = operatorId;
|
||||||
this.user_id = userId;
|
this.user_id = userId;
|
||||||
|
this.sub_type = subType
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user