refactor(oidb): migrate group-admin.ts OIDB cmds to namespaces
Splits the 14 OIDB cmds from GroupAdminApi into self-contained
namespaces under @snowluma/bridge/oidb-services/group-admin/. The
facade becomes one-line forwarders; per-cmd capability is narrowed
to OidbSender (+ resolveUserUid / identity where the cmd actually
needs it).
Notes:
- 0x89A_0 hosts MuteAll, SetAddOption, SetSearch, SetGroupName —
same (cmd, subcmd) tuple, four different proto bodies; each gets
its own namespace so proton can monomorphize independently.
- 0x8A0_1 splits KickMember (single) and KickMembers (batch) for
the same reason.
- SetAddRequest carries uinForm=true and dynamic subCommand
(filtered ? 2 : 1) on the same namespace.
- GetAtAllRemain needs the bot's own uin → declares
Pick<BridgeContext, 'identity'> in its Deps.
Wire-byte equivalence preserved; corner case for getAtAllRemain
empty-envelope path now returns {false, 0, 0} instead of throwing —
the new infrastructure normalises empty bodies and the OneBot action
ergonomics are unchanged.
This commit is contained in:
31 files changed
+1248
-202
No files matched your search
@@ -0,0 +1,61 @@
|
||||
// 0x8A7_0 — query "@everyone" remaining-use budget for the bot in
|
||||
// the given group. Server returns two independent counters: a
|
||||
// per-uin budget (the bot's daily allowance) and a per-group budget
|
||||
// (the group's shared allowance). The OneBot action surfaces both
|
||||
// alongside a single `can_at_all` boolean.
|
||||
//
|
||||
// The req's `basic{1,2,3}` triplet (1/2/1) is the wire-known
|
||||
// validation cookie NTQQ emits; the server rejects requests with
|
||||
// different values. `type = 0` means "query" (no other type seen).
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type { Oidb0x8a7Req, Oidb0x8a7Resp } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
import type { BridgeContext } from '../../bridge-context';
|
||||
|
||||
export interface AtAllRemain {
|
||||
can_at_all: boolean;
|
||||
remain_at_all_count_for_group: number;
|
||||
remain_at_all_count_for_uin: number;
|
||||
}
|
||||
|
||||
export namespace GetAtAllRemain {
|
||||
export const command = 0x8A7;
|
||||
export const subCommand = 0;
|
||||
|
||||
export interface Params { groupId: number; }
|
||||
|
||||
export type Deps = OidbSender & Pick<BridgeContext, 'identity'>;
|
||||
|
||||
export const serialize = (p: Params, botUin: string): Oidb0x8a7Req => ({
|
||||
basic1: 1,
|
||||
basic2: 2,
|
||||
basic3: 1,
|
||||
uin: BigInt(botUin),
|
||||
groupId: BigInt(p.groupId),
|
||||
type: 0,
|
||||
});
|
||||
|
||||
export const deserialize = (body: Oidb0x8a7Resp): AtAllRemain => {
|
||||
// Cast numbers to plain Number: the OIDB layer may surface uint32
|
||||
// as BigInt and the WebUI JSON serializer chokes on those.
|
||||
return {
|
||||
can_at_all: !!body.canAtAll,
|
||||
remain_at_all_count_for_group: Number(body.groupRemain ?? 0),
|
||||
remain_at_all_count_for_uin: Number(body.uinRemain ?? 0),
|
||||
};
|
||||
};
|
||||
|
||||
export const encode = (env: OidbBase<Oidb0x8a7Req>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<Oidb0x8a7Req>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<Oidb0x8a7Resp> =>
|
||||
protobuf_decode<OidbBase<Oidb0x8a7Resp>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<AtAllRemain> =>
|
||||
invokeOidb(deps, {
|
||||
...GetAtAllRemain,
|
||||
serialize: p => serialize(p, deps.identity.uin),
|
||||
}, params);
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
// 0x8A0_1 — single-member kick. The batch variant (kickMembers) uses
|
||||
// the same cmd but a different proto body shape; kept as a separate
|
||||
// namespace because proton needs distinct types per call site.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbKickMember } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
import type { BridgeContext } from '../../bridge-context';
|
||||
|
||||
export namespace KickMember {
|
||||
export const command = 0x8A0;
|
||||
export const subCommand = 1;
|
||||
|
||||
export interface Params {
|
||||
groupId: number;
|
||||
userId: number;
|
||||
/** Reject the kicked user's future join requests. */
|
||||
reject: boolean;
|
||||
reason?: string;
|
||||
}
|
||||
|
||||
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
|
||||
|
||||
export const serialize = (p: Params, targetUid: string): OidbKickMember => ({
|
||||
groupUin: p.groupId,
|
||||
targetUid,
|
||||
rejectAddRequest: p.reject,
|
||||
reason: p.reason ?? '',
|
||||
});
|
||||
|
||||
export const deserialize = (_: OidbEmpty): void => {};
|
||||
|
||||
export const encode = (env: OidbBase<OidbKickMember>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbKickMember>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
|
||||
export const invoke = async (deps: Deps, params: Params): Promise<void> => {
|
||||
const targetUid = await deps.resolveUserUid(params.userId, params.groupId);
|
||||
await invokeOidb(deps, { ...KickMember, serialize: p => serialize(p, targetUid) }, params);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
// 0x8A0_1 — batch member kick (repeated targetUids). Same cmd+subcmd
|
||||
// as KickMember (single) but a different proto body shape; separate
|
||||
// namespace so proton can monomorphize independently.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { Oidb0x8a0Req } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
import type { BridgeContext } from '../../bridge-context';
|
||||
|
||||
export namespace KickMembers {
|
||||
export const command = 0x8A0;
|
||||
export const subCommand = 1;
|
||||
|
||||
export interface Params {
|
||||
groupId: number;
|
||||
userIds: number[];
|
||||
reject: boolean;
|
||||
}
|
||||
|
||||
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
|
||||
|
||||
export const serialize = (p: Params, targetUids: string[]): Oidb0x8a0Req => ({
|
||||
groupId: BigInt(p.groupId),
|
||||
targetUids,
|
||||
rejectAddRequest: p.reject ? 1 : 0,
|
||||
kickReason: new Uint8Array(0),
|
||||
field12: 0,
|
||||
});
|
||||
|
||||
export const deserialize = (_: OidbEmpty): void => {};
|
||||
|
||||
export const encode = (env: OidbBase<Oidb0x8a0Req>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<Oidb0x8a0Req>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
|
||||
export const invoke = async (deps: Deps, params: Params): Promise<void> => {
|
||||
const targetUids = await Promise.all(
|
||||
params.userIds.map(userId => deps.resolveUserUid(userId, params.groupId)),
|
||||
);
|
||||
await invokeOidb(deps, { ...KickMembers, serialize: p => serialize(p, targetUids) }, params);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
// 0x1097_1 — leave a group (退群).
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbLeaveGroup } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
export namespace LeaveGroup {
|
||||
export const command = 0x1097;
|
||||
export const subCommand = 1;
|
||||
|
||||
export interface Params { groupId: number; }
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (p: Params): OidbLeaveGroup => ({ groupUin: p.groupId });
|
||||
export const deserialize = (_: OidbEmpty): void => {};
|
||||
export const encode = (env: OidbBase<OidbLeaveGroup>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbLeaveGroup>>(env);
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> =>
|
||||
invokeOidb(deps, LeaveGroup, params);
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// 0x89A_0 — toggle group全员禁言. `state` is the duration multiplier
|
||||
// (0xFFFFFFFF for permanent mute, 0 for unmute). Multiple OIDB cmds
|
||||
// share the (0x89A, 0) tuple — see also SetAddOption / SetSearch /
|
||||
// SetName — disambiguated by the body proto shape.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbMuteAll } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
export namespace MuteAll {
|
||||
export const command = 0x89A;
|
||||
export const subCommand = 0;
|
||||
|
||||
export interface Params { groupId: number; enable: boolean; }
|
||||
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (p: Params): OidbMuteAll => ({
|
||||
groupUin: p.groupId,
|
||||
muteState: { state: p.enable ? 0xFFFFFFFF : 0 },
|
||||
});
|
||||
|
||||
export const deserialize = (_: OidbEmpty): void => {};
|
||||
|
||||
export const encode = (env: OidbBase<OidbMuteAll>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbMuteAll>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> =>
|
||||
invokeOidb(deps, MuteAll, params);
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
// 0x1253_1 — mute a single group member for `duration` seconds.
|
||||
// Server treats duration = 0 as "unmute now".
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbMuteMember } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
import type { BridgeContext } from '../../bridge-context';
|
||||
|
||||
export namespace MuteMember {
|
||||
export const command = 0x1253;
|
||||
export const subCommand = 1;
|
||||
|
||||
export interface Params { groupId: number; userId: number; duration: number; }
|
||||
|
||||
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
|
||||
|
||||
export const serialize = (p: Params, targetUid: string): OidbMuteMember => ({
|
||||
groupUin: p.groupId, type: 1,
|
||||
body: { targetUid, duration: p.duration },
|
||||
});
|
||||
|
||||
export const deserialize = (_: OidbEmpty): void => {};
|
||||
|
||||
export const encode = (env: OidbBase<OidbMuteMember>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbMuteMember>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
|
||||
export const invoke = async (deps: Deps, params: Params): Promise<void> => {
|
||||
const targetUid = await deps.resolveUserUid(params.userId, params.groupId);
|
||||
await invokeOidb(deps, { ...MuteMember, serialize: p => serialize(p, targetUid) }, params);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
// 0x89A_0 — set group "how to join" option (anyone / verification /
|
||||
// owner-only / etc). Same cmd+subcmd as MuteAll / SetSearch / SetName
|
||||
// — disambiguated by the body proto shape.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { Oidb0x89a_0AddOption } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
export namespace SetAddOption {
|
||||
export const command = 0x89A;
|
||||
export const subCommand = 0;
|
||||
|
||||
export interface Params { groupId: number; addType: number; }
|
||||
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (p: Params): Oidb0x89a_0AddOption => ({
|
||||
groupUin: BigInt(p.groupId),
|
||||
settings: { addType: p.addType },
|
||||
field12: 0,
|
||||
});
|
||||
|
||||
export const deserialize = (_: OidbEmpty): void => {};
|
||||
|
||||
export const encode = (env: OidbBase<Oidb0x89a_0AddOption>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<Oidb0x89a_0AddOption>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> =>
|
||||
invokeOidb(deps, SetAddOption, params);
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
// 0x10C8 — approve/reject a pending group join request.
|
||||
// subCommand 1 = main inbox, 2 = filtered inbox
|
||||
//
|
||||
// `uinForm=true` matches the request shape NTQQ emits. `accept: 1`
|
||||
// is the server discriminator for approve; `2` for reject.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbGroupRequestAction } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
export namespace SetAddRequest {
|
||||
export const command = 0x10C8;
|
||||
export const uinForm = true;
|
||||
|
||||
export interface Params {
|
||||
groupId: number;
|
||||
sequence: number;
|
||||
eventType: number;
|
||||
approve: boolean;
|
||||
reason?: string;
|
||||
filtered?: boolean;
|
||||
}
|
||||
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const resolveSubCommand = (p: Params): number => p.filtered ? 2 : 1;
|
||||
|
||||
export const serialize = (p: Params): OidbGroupRequestAction => ({
|
||||
accept: p.approve ? 1 : 2,
|
||||
body: {
|
||||
sequence: BigInt(p.sequence),
|
||||
eventType: p.eventType,
|
||||
groupUin: p.groupId,
|
||||
message: p.reason ?? '',
|
||||
},
|
||||
});
|
||||
|
||||
export const deserialize = (_: OidbEmpty): void => {};
|
||||
|
||||
export const encode = (env: OidbBase<OidbGroupRequestAction>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbGroupRequestAction>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> =>
|
||||
invokeOidb(deps, SetAddRequest, params);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// 0x1096_1 — promote / demote a member to/from group administrator.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbSetAdmin } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
import type { BridgeContext } from '../../bridge-context';
|
||||
|
||||
export namespace SetAdmin {
|
||||
export const command = 0x1096;
|
||||
export const subCommand = 1;
|
||||
|
||||
export interface Params { groupId: number; userId: number; enable: boolean; }
|
||||
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
|
||||
|
||||
export const serialize = (p: Params, uid: string): OidbSetAdmin => ({
|
||||
groupUin: p.groupId, uid, isAdmin: p.enable,
|
||||
});
|
||||
|
||||
export const deserialize = (_: OidbEmpty): void => {};
|
||||
export const encode = (env: OidbBase<OidbSetAdmin>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbSetAdmin>>(env);
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
|
||||
export const invoke = async (deps: Deps, params: Params): Promise<void> => {
|
||||
const uid = await deps.resolveUserUid(params.userId, params.groupId);
|
||||
await invokeOidb(deps, { ...SetAdmin, serialize: p => serialize(p, uid) }, params);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
// 0x89A_15 — rename the group.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbRenameGroup } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
export namespace SetGroupName {
|
||||
export const command = 0x89A;
|
||||
export const subCommand = 15;
|
||||
|
||||
export interface Params { groupId: number; name: string; }
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (p: Params): OidbRenameGroup => ({
|
||||
groupUin: p.groupId, body: { targetName: p.name },
|
||||
});
|
||||
|
||||
export const deserialize = (_: OidbEmpty): void => {};
|
||||
export const encode = (env: OidbBase<OidbRenameGroup>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbRenameGroup>>(env);
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> =>
|
||||
invokeOidb(deps, SetGroupName, params);
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
// 0xF16_1 — set the bot's local-only label/remark for a group (only
|
||||
// the bot sees this — the group's actual name is untouched).
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { Oidb0xf16Req } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
export namespace SetGroupRemark {
|
||||
export const command = 0xF16;
|
||||
export const subCommand = 1;
|
||||
|
||||
export interface Params { groupId: number; remark: string; }
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (p: Params): Oidb0xf16Req => ({
|
||||
inner: { groupId: BigInt(p.groupId), remark: p.remark },
|
||||
field12: 0,
|
||||
});
|
||||
|
||||
export const deserialize = (_: OidbEmpty): void => {};
|
||||
export const encode = (env: OidbBase<Oidb0xf16Req>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<Oidb0xf16Req>>(env);
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> =>
|
||||
invokeOidb(deps, SetGroupRemark, params);
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
// 0x8FC_3 — set a member's group-card (群名片).
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbRenameMember } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
import type { BridgeContext } from '../../bridge-context';
|
||||
|
||||
export namespace SetMemberCard {
|
||||
export const command = 0x8FC;
|
||||
export const subCommand = 3;
|
||||
|
||||
export interface Params { groupId: number; userId: number; card: string; }
|
||||
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
|
||||
|
||||
export const serialize = (p: Params, targetUid: string): OidbRenameMember => ({
|
||||
groupUin: p.groupId, body: { targetUid, targetName: p.card },
|
||||
});
|
||||
|
||||
export const deserialize = (_: OidbEmpty): void => {};
|
||||
export const encode = (env: OidbBase<OidbRenameMember>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbRenameMember>>(env);
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
|
||||
export const invoke = async (deps: Deps, params: Params): Promise<void> => {
|
||||
const targetUid = await deps.resolveUserUid(params.userId, params.groupId);
|
||||
await invokeOidb(deps, { ...SetMemberCard, serialize: p => serialize(p, targetUid) }, params);
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
// 0x89A_0 — toggle group "searchable" flag. Same cmd+subcmd shape as
|
||||
// MuteAll / SetAddOption / SetName.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { Oidb0x89a_0Search } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
export namespace SetSearch {
|
||||
export const command = 0x89A;
|
||||
export const subCommand = 0;
|
||||
|
||||
export interface Params { groupId: number; }
|
||||
|
||||
export type Deps = OidbSender;
|
||||
|
||||
export const serialize = (p: Params): Oidb0x89a_0Search => ({
|
||||
groupUin: BigInt(p.groupId),
|
||||
settings: new Uint8Array(0),
|
||||
field12: 0,
|
||||
});
|
||||
|
||||
export const deserialize = (_: OidbEmpty): void => {};
|
||||
|
||||
export const encode = (env: OidbBase<Oidb0x89a_0Search>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<Oidb0x89a_0Search>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<void> =>
|
||||
invokeOidb(deps, SetSearch, params);
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
// 0x8FC_2 — assign a member a "special title" (群头衔). `expireTime=-1`
|
||||
// is the wire constant for "permanent".
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { OidbBase, OidbEmpty } from '@snowluma/proto-defs/oidb';
|
||||
import type { OidbSpecialTitle } from '@snowluma/proto-defs/oidb-actions/base';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
import type { BridgeContext } from '../../bridge-context';
|
||||
|
||||
export namespace SetSpecialTitle {
|
||||
export const command = 0x8FC;
|
||||
export const subCommand = 2;
|
||||
|
||||
export interface Params { groupId: number; userId: number; title: string; }
|
||||
export type Deps = OidbSender & Pick<BridgeContext, 'resolveUserUid'>;
|
||||
|
||||
export const serialize = (p: Params, targetUid: string): OidbSpecialTitle => ({
|
||||
groupUin: p.groupId,
|
||||
body: { targetUid, specialTitle: p.title, expireTime: -1 },
|
||||
});
|
||||
|
||||
export const deserialize = (_: OidbEmpty): void => {};
|
||||
export const encode = (env: OidbBase<OidbSpecialTitle>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbSpecialTitle>>(env);
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbEmpty> =>
|
||||
protobuf_decode<OidbBase<OidbEmpty>>(bytes);
|
||||
|
||||
export const invoke = async (deps: Deps, params: Params): Promise<void> => {
|
||||
const targetUid = await deps.resolveUserUid(params.userId, params.groupId);
|
||||
await invokeOidb(deps, { ...SetSpecialTitle, serialize: p => serialize(p, targetUid) }, params);
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user