fix(onebot): restore group and doubt request accounts
get_group_system_msg now keeps join and invite records, reports the inviter, and fills a missing requester nick from the user profile. get_doubt_friends_add_request returns the QQ number plus the request message, source, and time that QQ actually sends. Closes #400 Closes #401 Closes #402 Closes #403
This commit is contained in:
13 files changed
+418
-79
No files matched your search
@@ -7,19 +7,31 @@
|
||||
// uid (tag1) and reqTime (tag9) are HIGH confidence.
|
||||
|
||||
import { protobuf_decode, protobuf_encode } from '@snowluma/proton';
|
||||
import type { pb, pb_repeated, uint_32, uint_64 } from '@snowluma/proton';
|
||||
import type { OidbBase } from '@snowluma/proto-defs/oidb';
|
||||
import type {
|
||||
OidbDoubtGetReq, OidbDoubtGetResp,
|
||||
} from '@snowluma/proto-defs/oidb-actions/doubt-buddy';
|
||||
import { invokeOidb, type OidbSender } from '../../oidb-service';
|
||||
|
||||
interface OidbDoubtItemAccountOnTag1 {
|
||||
uin?: pb<1, uint_64>;
|
||||
}
|
||||
interface OidbDoubtGetRespAccountOnTag1 {
|
||||
status?: pb<1, uint_32>;
|
||||
body?: pb<2, { list?: pb_repeated<1, OidbDoubtItemAccountOnTag1> }>;
|
||||
}
|
||||
|
||||
export interface DoubtBuddyRequest {
|
||||
[key: string]: import('@snowluma/common/json').JsonValue;
|
||||
/** Opaque uid — pass back as `flag` to set_doubt_friends_add_request. */
|
||||
uid: string;
|
||||
user_id: number;
|
||||
nick: string;
|
||||
source: string;
|
||||
reason: string;
|
||||
msg: string;
|
||||
group_code: string;
|
||||
reqTime: number;
|
||||
}
|
||||
|
||||
@@ -39,17 +51,32 @@ export namespace GetDoubtBuddyReq {
|
||||
export const deserialize = (_ctx: Deps, body: OidbDoubtGetResp): DoubtBuddyRequest[] =>
|
||||
(body.body?.list ?? []).map((it) => ({
|
||||
uid: it.uid ?? '',
|
||||
user_id: Number(it.uin ?? 0),
|
||||
nick: it.nick ?? '',
|
||||
source: it.source ?? '',
|
||||
reason: it.reason ?? '',
|
||||
msg: it.msg ?? '',
|
||||
group_code: it.groupCode ?? '',
|
||||
reqTime: Number(it.reqTime ?? 0),
|
||||
}));
|
||||
|
||||
export const encode = (env: OidbBase<OidbDoubtGetReq>): Uint8Array =>
|
||||
protobuf_encode<OidbBase<OidbDoubtGetReq>>(env);
|
||||
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbDoubtGetResp> =>
|
||||
protobuf_decode<OidbBase<OidbDoubtGetResp>>(bytes);
|
||||
export const decode = (bytes: Uint8Array): OidbBase<OidbDoubtGetResp> => {
|
||||
const decoded = protobuf_decode<OidbBase<OidbDoubtGetResp>>(bytes);
|
||||
const numeric = protobuf_decode<OidbBase<OidbDoubtGetRespAccountOnTag1>>(bytes);
|
||||
const items = decoded.body?.body?.list ?? [];
|
||||
const numericItems = numeric.body?.body?.list ?? [];
|
||||
for (let i = 0; i < items.length; i++) {
|
||||
const item = items[i];
|
||||
if (!item) continue;
|
||||
if ((item.uin ?? 0n) === 0n && numericItems[i]?.uin) {
|
||||
item.uin = numericItems[i]!.uin;
|
||||
}
|
||||
}
|
||||
return decoded;
|
||||
};
|
||||
|
||||
export const invoke = (deps: Deps, params: Params): Promise<DoubtBuddyRequest[]> =>
|
||||
invokeOidb(deps, GetDoubtBuddyReq, params);
|
||||
|
||||
Reference in new issue
Block a user