mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2025-12-19 05:05:44 +08:00
Fix: Return mock data for user_id='all' in GetGroupMemberInfo
Instead of throwing an error, return a special mock member object representing "all members" when user_id='all'. This allows @all mentions to be processed normally without errors. Co-authored-by: sj817 <74231782+sj817@users.noreply.github.com>
This commit is contained in:
parent
76bf3719f1
commit
b6117ed205
@ -41,9 +41,28 @@ class GetGroupMemberInfo extends OneBotAction<Payload, OB11GroupMember> {
|
||||
}
|
||||
|
||||
async _handle (payload: Payload) {
|
||||
// 处理 'all' 的特殊情况,用于 @全体成员
|
||||
// 处理 @全体成员 的特殊情况
|
||||
if (payload.user_id === 'all') {
|
||||
throw new Error('无法获取全体成员的信息,user_id 不能为 "all"');
|
||||
return {
|
||||
group_id: +payload.group_id,
|
||||
user_id: 0,
|
||||
nickname: '全体成员',
|
||||
card: '全体成员',
|
||||
sex: 'unknown' as const,
|
||||
age: 0,
|
||||
area: '',
|
||||
level: '0',
|
||||
qq_level: 0,
|
||||
join_time: 0,
|
||||
last_sent_time: 0,
|
||||
title_expire_time: 0,
|
||||
unfriendly: false,
|
||||
card_changeable: false,
|
||||
is_robot: false,
|
||||
shut_up_timestamp: 0,
|
||||
role: 'member' as const,
|
||||
title: '',
|
||||
};
|
||||
}
|
||||
|
||||
const isNocache = this.parseBoolean(payload.no_cache ?? true);
|
||||
|
||||
@ -16,10 +16,6 @@ export default class SetGroupAdmin extends OneBotAction<Payload, null> {
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle (payload: Payload): Promise<null> {
|
||||
if (payload.user_id === 'all') {
|
||||
throw new Error('无法设置全体成员为管理员,user_id 不能为 "all"');
|
||||
}
|
||||
|
||||
const enable = typeof payload.enable === 'string' ? payload.enable === 'true' : !!payload.enable;
|
||||
const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
||||
if (!uid) throw new Error('get Uid Error');
|
||||
|
||||
@ -14,10 +14,6 @@ export default class SetGroupBan extends OneBotAction<Payload, null> {
|
||||
override actionName = ActionName.SetGroupBan;
|
||||
override payloadSchema = SchemaData;
|
||||
async _handle (payload: Payload): Promise<null> {
|
||||
if (payload.user_id === 'all') {
|
||||
throw new Error('无法禁言全体成员,请使用 set_group_whole_ban,user_id 不能为 "all"');
|
||||
}
|
||||
|
||||
const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
||||
if (!uid) throw new Error('uid error');
|
||||
const member_role = (await this.core.apis.GroupApi.getGroupMemberEx(payload.group_id.toString(), uid, true))?.role;
|
||||
|
||||
@ -15,10 +15,6 @@ export default class SetGroupCard extends OneBotAction<Payload, null> {
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle (payload: Payload): Promise<null> {
|
||||
if (payload.user_id === 'all') {
|
||||
throw new Error('无法设置全体成员的群名片,user_id 不能为 "all"');
|
||||
}
|
||||
|
||||
const member = await this.core.apis.GroupApi.getGroupMember(payload.group_id.toString(), payload.user_id.toString());
|
||||
if (member) await this.core.apis.GroupApi.setMemberCard(payload.group_id.toString(), member.uid, payload.card || '');
|
||||
return null;
|
||||
|
||||
@ -15,10 +15,6 @@ export default class SetGroupKick extends OneBotAction<Payload, null> {
|
||||
override payloadSchema = SchemaData;
|
||||
|
||||
async _handle (payload: Payload): Promise<null> {
|
||||
if (payload.user_id === 'all') {
|
||||
throw new Error('无法踢出全体成员,user_id 不能为 "all"');
|
||||
}
|
||||
|
||||
const rejectReq = payload.reject_add_request?.toString() === 'true';
|
||||
const uid = await this.core.apis.UserApi.getUidByUinV2(payload.user_id.toString());
|
||||
if (!uid) throw new Error('get Uid Error');
|
||||
|
||||
Loading…
Reference in New Issue
Block a user