mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
fix: kick group member event sub_type
This commit is contained in:
parent
f30dd81455
commit
d9377e4684
@ -15,6 +15,7 @@ export interface CheckVersion {
|
|||||||
version: string
|
version: string
|
||||||
}
|
}
|
||||||
export interface Config {
|
export interface Config {
|
||||||
|
imageRKey?: string;
|
||||||
ob11: OB11Config
|
ob11: OB11Config
|
||||||
token?: string
|
token?: string
|
||||||
heartInterval?: number // ms
|
heartInterval?: number // ms
|
||||||
|
@ -53,6 +53,7 @@ import {checkNewVersion, upgradeLLOneBot} from "../common/utils/upgrade";
|
|||||||
import {log} from "../common/utils/log";
|
import {log} from "../common/utils/log";
|
||||||
import {getConfigUtil} from "../common/config";
|
import {getConfigUtil} from "../common/config";
|
||||||
import {checkFfmpeg} from "../common/utils/video";
|
import {checkFfmpeg} from "../common/utils/video";
|
||||||
|
import {GroupDecreaseSubType, OB11GroupDecreaseEvent} from "../onebot11/event/notice/OB11GroupDecreaseEvent";
|
||||||
|
|
||||||
let running = false;
|
let running = false;
|
||||||
|
|
||||||
@ -296,11 +297,23 @@ function onLoad() {
|
|||||||
} else {
|
} else {
|
||||||
log("获取群通知的成员信息失败", notify, getGroup(notify.group.groupCode));
|
log("获取群通知的成员信息失败", notify, getGroup(notify.group.groupCode));
|
||||||
}
|
}
|
||||||
} else if (notify.type == GroupNotifyTypes.MEMBER_EXIT) {
|
} else if (notify.type == GroupNotifyTypes.MEMBER_EXIT || notify.type == GroupNotifyTypes.KICK_MEMBER) {
|
||||||
// log("有成员退出通知");
|
log("有成员退出通知", notify);
|
||||||
// const member1 = await getGroupMember(notify.group.groupCode, null, notify.user1.uid);
|
try {
|
||||||
// let groupDecreaseEvent = new OB11GroupDecreaseEvent(parseInt(notify.group.groupCode), parseInt(member1.uin))
|
const member1 = await NTQQUserApi.getUserDetailInfo(notify.user1.uid);
|
||||||
// postEvent(groupDecreaseEvent, true);
|
let operatorId = member1.uin;
|
||||||
|
let subType: GroupDecreaseSubType = "leave";
|
||||||
|
if (notify.user2.uid) {
|
||||||
|
// 是被踢的
|
||||||
|
const member2 = await getGroupMember(notify.group.groupCode, notify.user2.uid);
|
||||||
|
operatorId = member2.uin;
|
||||||
|
subType = "kick";
|
||||||
|
}
|
||||||
|
let groupDecreaseEvent = new OB11GroupDecreaseEvent(parseInt(notify.group.groupCode), parseInt(member1.uin), parseInt(operatorId), subType)
|
||||||
|
postOB11Event(groupDecreaseEvent, true);
|
||||||
|
} catch (e) {
|
||||||
|
log("获取群通知的成员信息失败", notify, e.stack.toString())
|
||||||
|
}
|
||||||
} else if ([GroupNotifyTypes.JOIN_REQUEST].includes(notify.type)) {
|
} else if ([GroupNotifyTypes.JOIN_REQUEST].includes(notify.type)) {
|
||||||
log("有加群请求");
|
log("有加群请求");
|
||||||
let groupRequestEvent = new OB11GroupRequestEvent();
|
let groupRequestEvent = new OB11GroupRequestEvent();
|
||||||
|
@ -32,7 +32,7 @@ export class NTQQUserApi{
|
|||||||
})
|
})
|
||||||
return result.profiles.get(uid)
|
return result.profiles.get(uid)
|
||||||
}
|
}
|
||||||
static async getUserDetailInfo(uid: string) {
|
static async getUserDetailInfo(uid: string, getLevel=false) {
|
||||||
// this.getUserInfo(uid);
|
// this.getUserInfo(uid);
|
||||||
let methodName = !isQQ998 ? NTQQApiMethod.USER_DETAIL_INFO : NTQQApiMethod.USER_DETAIL_INFO_WITH_BIZ_INFO
|
let methodName = !isQQ998 ? NTQQApiMethod.USER_DETAIL_INFO : NTQQApiMethod.USER_DETAIL_INFO_WITH_BIZ_INFO
|
||||||
const fetchInfo = async ()=>{
|
const fetchInfo = async ()=>{
|
||||||
@ -59,10 +59,10 @@ export class NTQQUserApi{
|
|||||||
return info
|
return info
|
||||||
}
|
}
|
||||||
// 首次请求两次才能拿到的等级信息
|
// 首次请求两次才能拿到的等级信息
|
||||||
if (!userInfoCache[uid]) {
|
if (!userInfoCache[uid] && getLevel) {
|
||||||
await fetchInfo()
|
await fetchInfo()
|
||||||
}
|
|
||||||
await sleep(1000);
|
await sleep(1000);
|
||||||
|
}
|
||||||
let userInfo = await fetchInfo()
|
let userInfo = await fetchInfo()
|
||||||
userInfoCache[uid] = userInfo
|
userInfoCache[uid] = userInfo
|
||||||
return userInfo
|
return userInfo
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
import {BrowserWindow} from 'electron';
|
import {BrowserWindow} from 'electron';
|
||||||
import {NTQQApiClass} from "./ntcall";
|
import {NTQQApiClass} from "./ntcall";
|
||||||
import {NTQQMsgApi, sendMessagePool} from "./api/msg"
|
import {NTQQMsgApi, sendMessagePool} from "./api/msg"
|
||||||
import {ChatType, Group, GroupMember, RawMessage, User} from "./types";
|
import {ChatType, Group, GroupMember, GroupMemberRole, RawMessage, User} from "./types";
|
||||||
import {friends, getGroupMember, groups, selfInfo, tempGroupCodeMap, uidMaps} from "../common/data";
|
import {friends, getGroupMember, groups, selfInfo, tempGroupCodeMap, uidMaps} from "../common/data";
|
||||||
import {OB11GroupDecreaseEvent} from "../onebot11/event/notice/OB11GroupDecreaseEvent";
|
import {OB11GroupDecreaseEvent} from "../onebot11/event/notice/OB11GroupDecreaseEvent";
|
||||||
import {v4 as uuidv4} from "uuid"
|
import {v4 as uuidv4} from "uuid"
|
||||||
@ -12,7 +12,6 @@ import {dbUtil} from "../common/db";
|
|||||||
import {NTQQGroupApi} from "./api/group";
|
import {NTQQGroupApi} from "./api/group";
|
||||||
import {log} from "../common/utils/log";
|
import {log} from "../common/utils/log";
|
||||||
import {sleep} from "../common/utils/helper";
|
import {sleep} from "../common/utils/helper";
|
||||||
import {OB11GroupCardEvent} from "../onebot11/event/notice/OB11GroupCardEvent";
|
|
||||||
|
|
||||||
export let hookApiCallbacks: Record<string, (apiReturn: any) => void> = {}
|
export let hookApiCallbacks: Record<string, (apiReturn: any) => void> = {}
|
||||||
|
|
||||||
@ -243,6 +242,11 @@ async function processGroupEvent(payload: {groupList: Group[]}) {
|
|||||||
newMembersSet.add(member.uin);
|
newMembersSet.add(member.uin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 判断bot是否是管理员,如果是管理员不需要从这里得知有人退群,这里的退群无法得知是主动退群还是被踢
|
||||||
|
let bot = await getGroupMember(group.groupCode, selfInfo.uin)
|
||||||
|
if (bot.role == GroupMemberRole.admin || bot.role == GroupMemberRole.owner) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
for (const member of oldMembers) {
|
for (const member of oldMembers) {
|
||||||
if (!newMembersSet.has(member.uin) && member.uin != selfInfo.uin) {
|
if (!newMembersSet.has(member.uin) && member.uin != selfInfo.uin) {
|
||||||
postOB11Event(new OB11GroupDecreaseEvent(parseInt(group.groupCode), parseInt(member.uin), parseInt(member.uin), "leave"));
|
postOB11Event(new OB11GroupDecreaseEvent(parseInt(group.groupCode), parseInt(member.uin), parseInt(member.uin), "leave"));
|
||||||
|
@ -172,7 +172,7 @@ export interface ArkElement {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const IMAGE_HTTP_HOST = "https://gchat.qpic.cn"
|
export const IMAGE_HTTP_HOST = "https://gchat.qpic.cn"
|
||||||
export const IMAGE_HTTP_HOST_NEW = "https://multimedia.nt.qq.com.cn"
|
export const IMAGE_HTTP_HOST_NT = "https://multimedia.nt.qq.com.cn"
|
||||||
|
|
||||||
export interface PicElement {
|
export interface PicElement {
|
||||||
originImageUrl: string; // http url, 没有host,host是https://gchat.qpic.cn/, 带download参数的是https://multimedia.nt.qq.com.cn
|
originImageUrl: string; // http url, 没有host,host是https://gchat.qpic.cn/, 带download参数的是https://multimedia.nt.qq.com.cn
|
||||||
|
@ -4,8 +4,9 @@ export enum GroupNotifyTypes {
|
|||||||
INVITED_JOIN = 4, // 有人接受了邀请入群
|
INVITED_JOIN = 4, // 有人接受了邀请入群
|
||||||
JOIN_REQUEST = 7,
|
JOIN_REQUEST = 7,
|
||||||
ADMIN_SET = 8,
|
ADMIN_SET = 8,
|
||||||
|
KICK_MEMBER = 9,
|
||||||
|
MEMBER_EXIT = 11, // 主动退出
|
||||||
ADMIN_UNSET = 12,
|
ADMIN_UNSET = 12,
|
||||||
MEMBER_EXIT = 11, // 主动退出?
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -15,6 +15,6 @@ export default class GoCQHTTPGetStrangerInfo extends BaseAction<{ user_id: numbe
|
|||||||
if (!uid) {
|
if (!uid) {
|
||||||
throw new Error("查无此人")
|
throw new Error("查无此人")
|
||||||
}
|
}
|
||||||
return OB11Constructor.stranger(await NTQQUserApi.getUserDetailInfo(uid))
|
return OB11Constructor.stranger(await NTQQUserApi.getUserDetailInfo(uid, true))
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -21,7 +21,7 @@ class GetGroupMemberInfo extends BaseAction<PayloadType, OB11GroupMember> {
|
|||||||
if (member) {
|
if (member) {
|
||||||
if (isNull(member.sex)){
|
if (isNull(member.sex)){
|
||||||
log("获取群成员详细信息")
|
log("获取群成员详细信息")
|
||||||
let info = (await NTQQUserApi.getUserDetailInfo(member.uid))
|
let info = (await NTQQUserApi.getUserDetailInfo(member.uid, true))
|
||||||
log("群成员详细信息结果", info)
|
log("群成员详细信息结果", info)
|
||||||
Object.assign(member, info);
|
Object.assign(member, info);
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,7 @@ import {
|
|||||||
GrayTipElementSubType,
|
GrayTipElementSubType,
|
||||||
Group,
|
Group,
|
||||||
GroupMember,
|
GroupMember,
|
||||||
IMAGE_HTTP_HOST, IMAGE_HTTP_HOST_NEW,
|
IMAGE_HTTP_HOST, IMAGE_HTTP_HOST_NT,
|
||||||
RawMessage,
|
RawMessage,
|
||||||
SelfInfo,
|
SelfInfo,
|
||||||
Sex,
|
Sex,
|
||||||
@ -43,7 +43,7 @@ import {OB11GroupDecreaseEvent} from "./event/notice/OB11GroupDecreaseEvent";
|
|||||||
|
|
||||||
export class OB11Constructor {
|
export class OB11Constructor {
|
||||||
static async message(msg: RawMessage): Promise<OB11Message> {
|
static async message(msg: RawMessage): Promise<OB11Message> {
|
||||||
|
let config = getConfigUtil().getConfig();
|
||||||
const {enableLocalFile2Url, ob11: {messagePostFormat}} = getConfigUtil().getConfig()
|
const {enableLocalFile2Url, ob11: {messagePostFormat}} = getConfigUtil().getConfig()
|
||||||
const message_type = msg.chatType == ChatType.group ? "group" : "private";
|
const message_type = msg.chatType == ChatType.group ? "group" : "private";
|
||||||
const resMsg: OB11Message = {
|
const resMsg: OB11Message = {
|
||||||
@ -140,24 +140,27 @@ export class OB11Constructor {
|
|||||||
// message_data["data"]["path"] = element.picElement.sourcePath
|
// message_data["data"]["path"] = element.picElement.sourcePath
|
||||||
const url = element.picElement.originImageUrl
|
const url = element.picElement.originImageUrl
|
||||||
const fileMd5 = element.picElement.md5HexStr
|
const fileMd5 = element.picElement.md5HexStr
|
||||||
|
let currentRKey = config.imageRKey || "CAQSKAB6JWENi5LMk0kc62l8Pm3Jn1dsLZHyRLAnNmHGoZ3y_gDZPqZt-64"
|
||||||
if (url) {
|
if (url) {
|
||||||
if (url.startsWith("/download")) {
|
if (url.startsWith("/download")) {
|
||||||
message_data["data"]["url"] = IMAGE_HTTP_HOST + url + "&rkey=CAQSKAB6JWENi5LMk0kc62l8Pm3Jn1dsLZHyRLAnNmHGoZ3y_gDZPqZt-64"
|
if (url.includes("&rkey=")) {
|
||||||
|
// 正则提取rkey
|
||||||
|
const rkey = url.match(/&rkey=([^&]+)/)[1]
|
||||||
|
log("图片url已有rkey", rkey)
|
||||||
|
if (rkey != currentRKey){
|
||||||
|
config.imageRKey = rkey
|
||||||
|
getConfigUtil().setConfig(config)
|
||||||
|
}
|
||||||
|
message_data["data"]["url"] = IMAGE_HTTP_HOST_NT + url
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
message_data["data"]["url"] = IMAGE_HTTP_HOST_NT + url + "&rkey=" + currentRKey
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
message_data["data"]["url"] = IMAGE_HTTP_HOST + url
|
message_data["data"]["url"] = IMAGE_HTTP_HOST + url
|
||||||
}
|
}
|
||||||
} else if (fileMd5 && element.picElement.fileUuid.indexOf("_") === -1) { // fileuuid有下划线的是Linux发送的,这个url是另外的格式,目前尚未得知如何组装
|
} else if (fileMd5) {
|
||||||
message_data["data"]["url"] = `${IMAGE_HTTP_HOST}/gchatpic_new/0/0-0-${fileMd5.toUpperCase()}/0`
|
message_data["data"]["url"] = `${IMAGE_HTTP_HOST}/gchatpic_new/0/0-0-${fileMd5.toUpperCase()}/0`
|
||||||
if (url.startsWith("/download") && url.includes("&rkey")){
|
|
||||||
message_data["data"]["url"] = IMAGE_HTTP_HOST_NEW + url
|
|
||||||
}
|
|
||||||
else if (!url.startsWith("/download")){
|
|
||||||
message_data["data"]["url"] = IMAGE_HTTP_HOST + url
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!message_data["data"]["url"]){
|
|
||||||
message_data["data"]["url"] = `${IMAGE_HTTP_HOST}/gchatpic_new/0/0-0-${md5HexStr.toUpperCase()}/0`
|
|
||||||
}
|
}
|
||||||
// message_data["data"]["file_id"] = element.picElement.fileUuid
|
// message_data["data"]["file_id"] = element.picElement.fileUuid
|
||||||
message_data["data"]["file_size"] = element.picElement.fileSize
|
message_data["data"]["file_size"] = element.picElement.fileSize
|
||||||
|
Loading…
x
Reference in New Issue
Block a user