旧实现走 OIDB 0x89a_0 但 settings 发空字节 → 服务端返 ok 却 no-op;action 也只收
group_id,没有设置搜索方式的参数(报告属实)。
真机 RE 定稿(tempserver,bot 为管理员的实群逐字段扫描 + GET 读回):
- 修改命令 = 0x89a_0(全量抓包确认,与 MuteAll 同命令,靠 body 形状区分)。结构
= {1:groupUin, 2: 只含被改字段的 GroupDetailInfo modify 子消息}。这是与 0x88D_0
群详情 GET **不同的消息域**(mute/shutUpTime 在此=tag17,在 GET 里却是字符串),
所以标签不能照搬 GET。
- 在 modify 子消息里逐 tag 试写、经 0x88D_0 GET 读回效果,定位:
noFingerOpen(关键词/群指纹搜索)=tag 35,noCodeFingerOpen(群号搜索/总开关)=tag 36;
再对照客户端「被搜索方式」三选下拉(私密/群号/群号+关键词)核实语义与 0/1 取值。
- proto-defs:settings 改为 Oidb0x89a_0SearchSettings 子消息,两 flag 用 pb_optional
(显式存在)——否则 proto3 丢 0 值,导致关闭(=0)被静默忽略。undefined 仍省略。
- set-search/bridge/action:透传 no_finger_open / no_code_finger_open;只下发提供的
字段(同 NapCat filter 机制、与 modify-group-ext-info 一致)。catalog regen。
- 编码测试锁定:0 值必发 tag 35/36、未提供则省略、命令为 0x89a_0。
typecheck 12 包干净;protocol 585 / onebot 521 / core 472 全绿。
112 lines
4.9 KiB
TypeScript
112 lines
4.9 KiB
TypeScript
import { GetAtAllRemain } from '@snowluma/protocol/oidb-services/group-admin/get-at-all-remain';
|
|
import { KickMember } from '@snowluma/protocol/oidb-services/group-admin/kick-member';
|
|
import { KickMembers } from '@snowluma/protocol/oidb-services/group-admin/kick-members';
|
|
import { LeaveGroup } from '@snowluma/protocol/oidb-services/group-admin/leave-group';
|
|
import { MuteAll } from '@snowluma/protocol/oidb-services/group-admin/mute-all';
|
|
import { MuteMember } from '@snowluma/protocol/oidb-services/group-admin/mute-member';
|
|
import { SetAddOption } from '@snowluma/protocol/oidb-services/group-admin/set-add-option';
|
|
import { SetAddRequest } from '@snowluma/protocol/oidb-services/group-admin/set-add-request';
|
|
import { SetAdmin } from '@snowluma/protocol/oidb-services/group-admin/set-admin';
|
|
import { SetGroupName } from '@snowluma/protocol/oidb-services/group-admin/set-group-name';
|
|
import { SetGroupRemark } from '@snowluma/protocol/oidb-services/group-admin/set-group-remark';
|
|
import { SetMemberCard } from '@snowluma/protocol/oidb-services/group-admin/set-member-card';
|
|
import { SetSearch } from '@snowluma/protocol/oidb-services/group-admin/set-search';
|
|
import { SetSpecialTitle } from '@snowluma/protocol/oidb-services/group-admin/set-special-title';
|
|
import { ModifyGroupExtInfo } from '@snowluma/protocol/oidb-services/group-admin/modify-group-ext-info';
|
|
import type { BridgeContext } from '../bridge-context';
|
|
|
|
export class GroupAdminApi {
|
|
constructor(private readonly ctx: BridgeContext) { }
|
|
|
|
/** Set the group's robot-add option (switch / examine) via group ext-info. */
|
|
setRobotAddOption(groupId: number, robotMemberSwitch?: number, robotMemberExamine?: number): Promise<void> {
|
|
return ModifyGroupExtInfo.invoke(this.ctx, { groupId, robotMemberSwitch, robotMemberExamine });
|
|
}
|
|
|
|
muteMember(groupId: number, userId: number, duration: number): Promise<void> {
|
|
return MuteMember.invoke(this.ctx, { groupId, userId, duration });
|
|
}
|
|
|
|
muteAll(groupId: number, enable: boolean): Promise<void> {
|
|
return MuteAll.invoke(this.ctx, { groupId, enable });
|
|
}
|
|
|
|
setAddOption(groupId: number, addType: number): Promise<void> {
|
|
return SetAddOption.invoke(this.ctx, { groupId, addType });
|
|
}
|
|
|
|
setSearch(groupId: number, noFingerOpen?: number, noCodeFingerOpen?: number): Promise<void> {
|
|
return SetSearch.invoke(this.ctx, { groupId, noFingerOpen, noCodeFingerOpen });
|
|
}
|
|
|
|
setAddRequest(
|
|
groupId: number, sequence: number, eventType: number,
|
|
approve: boolean, reason = '', filtered = false,
|
|
): Promise<void> {
|
|
return SetAddRequest.invoke(this.ctx, { groupId, sequence, eventType, approve, reason, filtered });
|
|
}
|
|
|
|
kickMember(groupId: number, userId: number, reject: boolean, reason = ''): Promise<void> {
|
|
return KickMember.invoke(this.ctx, { groupId, userId, reject, reason });
|
|
}
|
|
|
|
kickMembers(groupId: number, userIds: number[], reject: boolean): Promise<void> {
|
|
return KickMembers.invoke(this.ctx, { groupId, userIds, reject });
|
|
}
|
|
|
|
async leave(groupId: number): Promise<void> {
|
|
await LeaveGroup.invoke(this.ctx, { groupId });
|
|
// The server doesn't push a member-decrease back to the member who left of
|
|
// its own accord, so synthesize the self group_member_leave here — otherwise
|
|
// downstream never sees notice.group_decrease and keeps a "zombie" group in
|
|
// its cache (#133). Also drop the group from our own roster.
|
|
const selfUin = Number(this.ctx.identity.uin) || 0;
|
|
const selfUid = this.ctx.identity.selfUid ?? '';
|
|
await this.ctx.events.emit({
|
|
kind: 'group_member_leave',
|
|
time: Math.floor(Date.now() / 1000),
|
|
selfUin,
|
|
groupId,
|
|
userUin: selfUin,
|
|
operatorUin: selfUin,
|
|
userUid: selfUid,
|
|
operatorUid: selfUid,
|
|
leaveType: 'leave',
|
|
});
|
|
this.ctx.identity.forgetGroup(groupId);
|
|
}
|
|
|
|
setAdmin(groupId: number, userId: number, enable: boolean): Promise<void> {
|
|
return SetAdmin.invoke(this.ctx, { groupId, userId, enable });
|
|
}
|
|
|
|
setCard(groupId: number, userId: number, card: string): Promise<void> {
|
|
return SetMemberCard.invoke(this.ctx, { groupId, userId, card });
|
|
}
|
|
|
|
setName(groupId: number, name: string): Promise<void> {
|
|
return SetGroupName.invoke(this.ctx, { groupId, name });
|
|
}
|
|
|
|
setSpecialTitle(groupId: number, userId: number, title: string): Promise<void> {
|
|
return SetSpecialTitle.invoke(this.ctx, { groupId, userId, title });
|
|
}
|
|
|
|
/**
|
|
* The bot's local-only label for a group. Lives here rather than
|
|
* `FriendApi` because the semantic is "operate on a group" rather
|
|
* than "operate on a contact list".
|
|
*/
|
|
setRemark(groupId: number, remark: string): Promise<void> {
|
|
return SetGroupRemark.invoke(this.ctx, { groupId, remark });
|
|
}
|
|
|
|
getAtAllRemain(groupId: number): Promise<{
|
|
can_at_all: boolean;
|
|
remain_at_all_count_for_group: number;
|
|
remain_at_all_count_for_uin: number;
|
|
}> {
|
|
return GetAtAllRemain.invoke(this.ctx, { groupId });
|
|
}
|
|
}
|