mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-07-19 12:03:37 +00:00
Compare commits
14 Commits
Author | SHA1 | Date | |
---|---|---|---|
![]() |
76b9506395 | ||
![]() |
f1cf636aa2 | ||
![]() |
312dcd0e13 | ||
![]() |
42c2419613 | ||
![]() |
8f7f748e82 | ||
![]() |
7ad3bad1be | ||
![]() |
5cd682e69f | ||
![]() |
5d57780e84 | ||
![]() |
f399955204 | ||
![]() |
770652fe6b | ||
![]() |
9ed5fa8c67 | ||
![]() |
5a4ad29727 | ||
![]() |
1eda3f2e33 | ||
![]() |
95cb95ef96 |
@@ -4,7 +4,7 @@
|
|||||||
"name": "NapCatQQ",
|
"name": "NapCatQQ",
|
||||||
"slug": "NapCat.Framework",
|
"slug": "NapCat.Framework",
|
||||||
"description": "高性能的 OneBot 11 协议实现",
|
"description": "高性能的 OneBot 11 协议实现",
|
||||||
"version": "4.7.68",
|
"version": "4.7.74",
|
||||||
"icon": "./logo.png",
|
"icon": "./logo.png",
|
||||||
"authors": [
|
"authors": [
|
||||||
{
|
{
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
"name": "napcat",
|
"name": "napcat",
|
||||||
"private": true,
|
"private": true,
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"version": "4.7.68",
|
"version": "4.7.74",
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build:universal": "npm run build:webui && vite build --mode universal || exit 1",
|
"build:universal": "npm run build:webui && vite build --mode universal || exit 1",
|
||||||
"build:framework": "npm run build:webui && vite build --mode framework || exit 1",
|
"build:framework": "npm run build:webui && vite build --mode framework || exit 1",
|
||||||
|
@@ -13,11 +13,15 @@ export class NapCatPathWrapper {
|
|||||||
constructor(mainPath: string = dirname(fileURLToPath(import.meta.url))) {
|
constructor(mainPath: string = dirname(fileURLToPath(import.meta.url))) {
|
||||||
this.binaryPath = mainPath;
|
this.binaryPath = mainPath;
|
||||||
let writePath: string;
|
let writePath: string;
|
||||||
if (os.platform() === 'darwin') {
|
|
||||||
|
if (process.env['NAPCAT_WORKDIR']) {
|
||||||
|
writePath = process.env['NAPCAT_WORKDIR'];
|
||||||
|
} else if (os.platform() === 'darwin') {
|
||||||
writePath = path.join(os.homedir(), 'Library', 'Application Support', 'QQ', 'NapCat');
|
writePath = path.join(os.homedir(), 'Library', 'Application Support', 'QQ', 'NapCat');
|
||||||
} else {
|
} else {
|
||||||
writePath = this.binaryPath;
|
writePath = this.binaryPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.logsPath = path.join(writePath, 'logs');
|
this.logsPath = path.join(writePath, 'logs');
|
||||||
this.configPath = path.join(writePath, 'config');
|
this.configPath = path.join(writePath, 'config');
|
||||||
this.cachePath = path.join(writePath, 'cache');
|
this.cachePath = path.join(writePath, 'cache');
|
||||||
|
@@ -1 +1 @@
|
|||||||
export const napCatVersion = '4.7.68';
|
export const napCatVersion = '4.7.74';
|
||||||
|
Binary file not shown.
Binary file not shown.
23
src/onebot/action/extends/SetGroupKickMembers.ts
Normal file
23
src/onebot/action/extends/SetGroupKickMembers.ts
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
import { OneBotAction } from '@/onebot/action/OneBotAction';
|
||||||
|
import { ActionName } from '@/onebot/action/router';
|
||||||
|
import { Static, Type } from '@sinclair/typebox';
|
||||||
|
|
||||||
|
const SchemaData = Type.Object({
|
||||||
|
group_id: Type.String(),
|
||||||
|
user_id: Type.Array(Type.String()),
|
||||||
|
reject_add_request: Type.Optional(Type.Union([Type.Boolean(), Type.String()])),
|
||||||
|
});
|
||||||
|
|
||||||
|
type Payload = Static<typeof SchemaData>;
|
||||||
|
|
||||||
|
export default class SetGroupKickMembers extends OneBotAction<Payload, null> {
|
||||||
|
override actionName = ActionName.SetGroupKickMembers;
|
||||||
|
override payloadSchema = SchemaData;
|
||||||
|
|
||||||
|
async _handle(payload: Payload): Promise<null> {
|
||||||
|
const rejectReq = payload.reject_add_request?.toString() == 'true';
|
||||||
|
const uids: string[] = await Promise.all(payload.user_id.map(async uin => await this.core.apis.UserApi.getUidByUinV2(uin)));
|
||||||
|
await this.core.apis.GroupApi.kickMember(payload.group_id.toString(), uids.filter(uid => !!uid), rejectReq);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@@ -119,10 +119,12 @@ import { GetDoubtFriendsAddRequest } from './new/GetDoubtFriendsAddRequest';
|
|||||||
import SetGroupAddOption from './extends/SetGroupAddOption';
|
import SetGroupAddOption from './extends/SetGroupAddOption';
|
||||||
import SetGroupSearch from './extends/SetGroupSearch';
|
import SetGroupSearch from './extends/SetGroupSearch';
|
||||||
import SetGroupRobotAddOption from './extends/SetGroupRobotAddOption';
|
import SetGroupRobotAddOption from './extends/SetGroupRobotAddOption';
|
||||||
|
import SetGroupKickMembers from './extends/SetGroupKickMembers';
|
||||||
|
|
||||||
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) {
|
export function createActionMap(obContext: NapCatOneBot11Adapter, core: NapCatCore) {
|
||||||
|
|
||||||
const actionHandlers = [
|
const actionHandlers = [
|
||||||
|
new SetGroupKickMembers(obContext, core),
|
||||||
new SetGroupAddOption(obContext, core),
|
new SetGroupAddOption(obContext, core),
|
||||||
new SetGroupRobotAddOption(obContext, core),
|
new SetGroupRobotAddOption(obContext, core),
|
||||||
new SetGroupSearch(obContext, core),
|
new SetGroupSearch(obContext, core),
|
||||||
|
@@ -10,6 +10,7 @@ export interface InvalidCheckResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export const ActionName = {
|
export const ActionName = {
|
||||||
|
SetGroupKickMembers: 'set_group_kick_members',
|
||||||
SetGroupRobotAddOption: 'set_group_robot_add_option',
|
SetGroupRobotAddOption: 'set_group_robot_add_option',
|
||||||
SetGroupAddOption: 'set_group_add_option',
|
SetGroupAddOption: 'set_group_add_option',
|
||||||
SetGroupSearch: 'set_group_search',
|
SetGroupSearch: 'set_group_search',
|
||||||
|
@@ -1209,7 +1209,6 @@ export class OneBotMsgApi {
|
|||||||
async waitGroupNotify(groupUin: string, memberUid?: string, operatorUid?: string) {
|
async waitGroupNotify(groupUin: string, memberUid?: string, operatorUid?: string) {
|
||||||
const groupRole = this.core.apis.GroupApi.groupMemberCache.get(groupUin)?.get(this.core.selfInfo.uid.toString())?.role;
|
const groupRole = this.core.apis.GroupApi.groupMemberCache.get(groupUin)?.get(this.core.selfInfo.uid.toString())?.role;
|
||||||
const isAdminOrOwner = groupRole === 3 || groupRole === 4;
|
const isAdminOrOwner = groupRole === 3 || groupRole === 4;
|
||||||
|
|
||||||
if (isAdminOrOwner && !operatorUid) {
|
if (isAdminOrOwner && !operatorUid) {
|
||||||
let dataNotify: GroupNotify | undefined;
|
let dataNotify: GroupNotify | undefined;
|
||||||
await this.core.eventWrapper.registerListen('NodeIKernelGroupListener/onGroupNotifiesUpdated',
|
await this.core.eventWrapper.registerListen('NodeIKernelGroupListener/onGroupNotifiesUpdated',
|
||||||
@@ -1239,7 +1238,7 @@ export class OneBotMsgApi {
|
|||||||
const operatorUid = await this.waitGroupNotify(
|
const operatorUid = await this.waitGroupNotify(
|
||||||
groupChange.groupUin.toString(),
|
groupChange.groupUin.toString(),
|
||||||
groupChange.memberUid,
|
groupChange.memberUid,
|
||||||
groupChange.operatorInfo ? Buffer.from(groupChange.operatorInfo).toString() : ''
|
groupChange.operatorInfo ? new TextDecoder('utf-8').decode(groupChange.operatorInfo) : undefined
|
||||||
);
|
);
|
||||||
return new OB11GroupIncreaseEvent(
|
return new OB11GroupIncreaseEvent(
|
||||||
this.core,
|
this.core,
|
||||||
@@ -1251,13 +1250,42 @@ export class OneBotMsgApi {
|
|||||||
|
|
||||||
} else if (SysMessage.contentHead.type == 34 && SysMessage.body?.msgContent) {
|
} else if (SysMessage.contentHead.type == 34 && SysMessage.body?.msgContent) {
|
||||||
const groupChange = new NapProtoMsg(GroupChange).decode(SysMessage.body.msgContent);
|
const groupChange = new NapProtoMsg(GroupChange).decode(SysMessage.body.msgContent);
|
||||||
// 自身被踢出时operatorInfo会是一个protobuf 否则大多数情况为一个string
|
|
||||||
|
let operator_uid_parse: string | undefined = undefined;
|
||||||
|
if (groupChange.operatorInfo) {
|
||||||
|
// 先判断是否可能是protobuf(自身被踢出或以0a开头)
|
||||||
|
if (groupChange.decreaseType === 3 || Buffer.from(groupChange.operatorInfo).toString('hex').startsWith('0a')) {
|
||||||
|
// 可能是protobuf,尝试解析
|
||||||
|
try {
|
||||||
|
operator_uid_parse = new NapProtoMsg(GroupChangeInfo).decode(groupChange.operatorInfo).operator?.operatorUid;
|
||||||
|
} catch (error) {
|
||||||
|
// protobuf解析失败,fallback到字符串解析
|
||||||
|
try {
|
||||||
|
const decoded = new TextDecoder('utf-8').decode(groupChange.operatorInfo);
|
||||||
|
// 检查是否包含非ASCII字符,如果包含则丢弃
|
||||||
|
const isAsciiOnly = [...decoded].every(char => char.charCodeAt(0) >= 32 && char.charCodeAt(0) <= 126);
|
||||||
|
operator_uid_parse = isAsciiOnly ? decoded : '';
|
||||||
|
} catch (e2) {
|
||||||
|
operator_uid_parse = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// 直接进行字符串解析
|
||||||
|
try {
|
||||||
|
const decoded = new TextDecoder('utf-8').decode(groupChange.operatorInfo);
|
||||||
|
// 检查是否包含非ASCII字符,如果包含则丢弃
|
||||||
|
const isAsciiOnly = [...decoded].every(char => char.charCodeAt(0) >= 32 && char.charCodeAt(0) <= 126);
|
||||||
|
operator_uid_parse = isAsciiOnly ? decoded : '';
|
||||||
|
} catch (e) {
|
||||||
|
operator_uid_parse = '';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
const operatorUid = await this.waitGroupNotify(
|
const operatorUid = await this.waitGroupNotify(
|
||||||
groupChange.groupUin.toString(),
|
groupChange.groupUin.toString(),
|
||||||
groupChange.memberUid,
|
groupChange.memberUid,
|
||||||
groupChange.decreaseType === 3 && groupChange.operatorInfo ?
|
operator_uid_parse
|
||||||
new NapProtoMsg(GroupChangeInfo).decode(groupChange.operatorInfo).operator?.operatorUid :
|
|
||||||
groupChange.operatorInfo?.toString()
|
|
||||||
);
|
);
|
||||||
if (groupChange.memberUid === this.core.selfInfo.uid) {
|
if (groupChange.memberUid === this.core.selfInfo.uid) {
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
|
Reference in New Issue
Block a user