implement some onebot actions (#26)
* feat: implement more group admin action (kick members and set search and set add type) * feat: implement some user extend func (set group mark \\ get custom emoji) * feat: implement get send emoji his
This commit is contained in:
1 parent
bf0a89e221
commit
df5e3a26ac
7 files changed
+300
-1
No files matched your search
@@ -9,10 +9,13 @@ import { computeHashes, computeMd5, loadBinarySource } from './highway/utils';
|
|||||||
import { buildSendElems } from './builders/element-builder';
|
import { buildSendElems } from './builders/element-builder';
|
||||||
import { parseMsgPush } from './handlers/msg-push-handler';
|
import { parseMsgPush } from './handlers/msg-push-handler';
|
||||||
import type { ForwardNodePayload, MessageElement } from './events';
|
import type { ForwardNodePayload, MessageElement } from './events';
|
||||||
|
import { createLogger } from '../utils/logger';
|
||||||
import { PushMsgSchema } from './proto/message';
|
import { PushMsgSchema } from './proto/message';
|
||||||
import {
|
import {
|
||||||
OidbMuteMemberSchema,
|
OidbMuteMemberSchema,
|
||||||
OidbMuteAllSchema,
|
OidbMuteAllSchema,
|
||||||
|
Oidb0x89a_0AddOptionSchema,
|
||||||
|
Oidb0x89a_0SearchSchema,
|
||||||
OidbKickMemberSchema,
|
OidbKickMemberSchema,
|
||||||
OidbLeaveGroupSchema,
|
OidbLeaveGroupSchema,
|
||||||
OidbFriendRequestActionSchema,
|
OidbFriendRequestActionSchema,
|
||||||
@@ -49,6 +52,10 @@ import {
|
|||||||
OidbSetProfileSchema,
|
OidbSetProfileSchema,
|
||||||
Oidb0x7edReqSchema,
|
Oidb0x7edReqSchema,
|
||||||
Oidb0x7edRespSchema,
|
Oidb0x7edRespSchema,
|
||||||
|
Oidb0x8a0ReqSchema,
|
||||||
|
Oidb0x8a0RespSchema,
|
||||||
|
Oidb0xf16ReqSchema,
|
||||||
|
Oidb0xf16RespSchema,
|
||||||
Oidb0x8a7RespSchema,
|
Oidb0x8a7RespSchema,
|
||||||
Oidb0x8a7ReqSchema,
|
Oidb0x8a7ReqSchema,
|
||||||
Oidb0xe17RespSchema,
|
Oidb0xe17RespSchema,
|
||||||
@@ -65,6 +72,10 @@ import {
|
|||||||
Oidb0x112eRespSchema,
|
Oidb0x112eRespSchema,
|
||||||
Oidb0xeb7ReqSchema,
|
Oidb0xeb7ReqSchema,
|
||||||
Oidb0xeb7RespSchema,
|
Oidb0xeb7RespSchema,
|
||||||
|
FaceroamOpReqSchema,
|
||||||
|
FaceroamOpRespSchema,
|
||||||
|
Oidb0x9083ReqSchema,
|
||||||
|
Oidb0x9083RespSchema,
|
||||||
} from './proto/oidb-action';
|
} from './proto/oidb-action';
|
||||||
import { FileUploadExtSchema } from './proto/highway';
|
import { FileUploadExtSchema } from './proto/highway';
|
||||||
import {
|
import {
|
||||||
@@ -76,6 +87,8 @@ import {
|
|||||||
} from './proto/longmsg';
|
} from './proto/longmsg';
|
||||||
import { gzipSync, gunzipSync } from 'zlib';
|
import { gzipSync, gunzipSync } from 'zlib';
|
||||||
|
|
||||||
|
const log = createLogger('BridgeActions');
|
||||||
|
|
||||||
export interface GroupFileInfo {
|
export interface GroupFileInfo {
|
||||||
fileId: string;
|
fileId: string;
|
||||||
fileName: string;
|
fileName: string;
|
||||||
@@ -407,6 +420,11 @@ export async function setFriendRemark(bridge: Bridge, userId: number, remark: st
|
|||||||
{ targetUid: uid, remark }, OidbSetFriendRemarkSchema);
|
{ targetUid: uid, remark }, OidbSetFriendRemarkSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function setGroupRemark(bridge: Bridge, groupId: number, remark: string): Promise<void> {
|
||||||
|
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0xf16_1', 0xF16, 1,
|
||||||
|
{ inner: { groupId: BigInt(groupId), remark }, field12: 0 }, Oidb0xf16ReqSchema);
|
||||||
|
}
|
||||||
|
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
// Group file count
|
// Group file count
|
||||||
// ---------------------------------------------------------------------------
|
// ---------------------------------------------------------------------------
|
||||||
@@ -438,12 +456,28 @@ export async function muteGroupAll(bridge: Bridge, groupId: number, enable: bool
|
|||||||
{ groupUin: groupId, muteState: { state: enable ? 0xFFFFFFFF : 0 } }, OidbMuteAllSchema);
|
{ groupUin: groupId, muteState: { state: enable ? 0xFFFFFFFF : 0 } }, OidbMuteAllSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function setGroupAddOption(bridge: Bridge, groupId: number, addType: number): Promise<void> {
|
||||||
|
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x89a_0', 0x89A, 0,
|
||||||
|
{ groupUin: BigInt(groupId), settings: { addType }, field12: 0 }, Oidb0x89a_0AddOptionSchema);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function setGroupSearch(bridge: Bridge, groupId: number): Promise<void> {
|
||||||
|
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x89a_0', 0x89A, 0,
|
||||||
|
{ groupUin: BigInt(groupId), settings: new Uint8Array(0), field12: 0 }, Oidb0x89a_0SearchSchema);
|
||||||
|
}
|
||||||
|
|
||||||
export async function kickGroupMember(bridge: Bridge, groupId: number, userId: number, reject: boolean, reason = ''): Promise<void> {
|
export async function kickGroupMember(bridge: Bridge, groupId: number, userId: number, reject: boolean, reason = ''): Promise<void> {
|
||||||
const uid = await resolveUserUid(bridge, userId, groupId);
|
const uid = await resolveUserUid(bridge, userId, groupId);
|
||||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x8a0_1', 0x8A0, 1,
|
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x8a0_1', 0x8A0, 1,
|
||||||
{ groupUin: groupId, targetUid: uid, rejectAddRequest: reject, reason }, OidbKickMemberSchema);
|
{ groupUin: groupId, targetUid: uid, rejectAddRequest: reject, reason }, OidbKickMemberSchema);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function kickGroupMembers(bridge: Bridge, groupId: number, userIds: number[], reject: boolean): Promise<void> {
|
||||||
|
const targetUids = await Promise.all(userIds.map(userId => resolveUserUid(bridge, userId, groupId)));
|
||||||
|
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x8a0_1', 0x8A0, 1,
|
||||||
|
{ groupId: BigInt(groupId), targetUids, rejectAddRequest: reject ? 1 : 0, kickReason: new Uint8Array(0), field12: 0 }, Oidb0x8a0ReqSchema);
|
||||||
|
}
|
||||||
|
|
||||||
export async function leaveGroup(bridge: Bridge, groupId: number): Promise<void> {
|
export async function leaveGroup(bridge: Bridge, groupId: number): Promise<void> {
|
||||||
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x1097_1', 0x1097, 1,
|
await sendOidbAndCheck(bridge, 'OidbSvcTrpcTcp.0x1097_1', 0x1097, 1,
|
||||||
{ groupUin: groupId }, OidbLeaveGroupSchema);
|
{ groupUin: groupId }, OidbLeaveGroupSchema);
|
||||||
@@ -1732,3 +1766,49 @@ export async function setAvatar(
|
|||||||
await uploadHighwayHttp(bridge, session, 90, loaded.bytes, hashes.md5, new Uint8Array(0));
|
await uploadHighwayHttp(bridge, session, 90, loaded.bytes, hashes.md5, new Uint8Array(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export async function fetchCustomFace(bridge: Bridge, count: number = 10): Promise<string[]> {
|
||||||
|
const req = {
|
||||||
|
inner: { field1: 1, osVersion: '10.0.26200', qqVersion: '9.9.28-46928' },
|
||||||
|
uin: BigInt(bridge.qqInfo.uin),
|
||||||
|
field3: 1,
|
||||||
|
field6: 1,
|
||||||
|
};
|
||||||
|
const request = protoEncode(req, FaceroamOpReqSchema);
|
||||||
|
const result = await bridge.sendRawPacket('Faceroam.OpReq', request);
|
||||||
|
if (!result.success || !result.gotResponse || !result.responseData) {
|
||||||
|
throw new Error(result.errorMessage || 'fetch custom face failed');
|
||||||
|
}
|
||||||
|
const resp = protoDecode(result.responseData, FaceroamOpRespSchema);
|
||||||
|
if (!resp || (resp as any).retCode !== 0) {
|
||||||
|
throw new Error(`fetch custom face error: ${(resp as any)?.message || 'unknown'}`);
|
||||||
|
}
|
||||||
|
const faceIds = (resp as any).item?.faceIds || [];
|
||||||
|
return faceIds.slice(0, count).map((id: string) => `https://p.qpic.cn/qq_expression/${bridge.qqInfo.uin}/${id}/0`);
|
||||||
|
}
|
||||||
|
|
||||||
|
export async function getEmojiLikes(
|
||||||
|
bridge: Bridge,
|
||||||
|
groupId: number,
|
||||||
|
sequence: number,
|
||||||
|
emojiId: string,
|
||||||
|
emojiType: number = 1,
|
||||||
|
count: number = 10,
|
||||||
|
cookie: string = ''
|
||||||
|
): Promise<{ users: Array<{ uin: number }>, cookie: string, isLast: boolean }> {
|
||||||
|
const req = {
|
||||||
|
groupId: BigInt(groupId),
|
||||||
|
sequence,
|
||||||
|
emojiType,
|
||||||
|
emojiId,
|
||||||
|
cookie: cookie ? Buffer.from(cookie, 'base64') : new Uint8Array(0),
|
||||||
|
field7: 0,
|
||||||
|
count,
|
||||||
|
field12: 1,
|
||||||
|
};
|
||||||
|
const resp = await sendOidbAndDecode<any>(bridge, 'OidbSvcTrpcTcp.0x9083_1', 0x9083, 1, req, Oidb0x9083ReqSchema, Oidb0x9083RespSchema);
|
||||||
|
const uin = resp?.inner?.userInfo?.uin;
|
||||||
|
const users = uin ? [{ uin: Number(uin) }] : [];
|
||||||
|
const respCookie = resp?.cookie ? Buffer.from(resp.cookie).toString('base64') : '';
|
||||||
|
return { users, cookie: respCookie, isLast: !respCookie };
|
||||||
|
}
|
||||||
|
|
||||||
@@ -30,7 +30,10 @@ import type { WebHonorType } from './web/group-honor';
|
|||||||
import {
|
import {
|
||||||
muteGroupMember as muteGroupMember_,
|
muteGroupMember as muteGroupMember_,
|
||||||
muteGroupAll as muteGroupAll_,
|
muteGroupAll as muteGroupAll_,
|
||||||
|
setGroupAddOption as setGroupAddOption_,
|
||||||
|
setGroupSearch as setGroupSearch_,
|
||||||
kickGroupMember as kickGroupMember_,
|
kickGroupMember as kickGroupMember_,
|
||||||
|
kickGroupMembers as kickGroupMembers_,
|
||||||
leaveGroup as leaveGroup_,
|
leaveGroup as leaveGroup_,
|
||||||
setGroupAdmin as setGroupAdmin_,
|
setGroupAdmin as setGroupAdmin_,
|
||||||
setGroupCard as setGroupCard_,
|
setGroupCard as setGroupCard_,
|
||||||
@@ -64,6 +67,7 @@ import {
|
|||||||
markPrivateMessageRead as markGroupMsgAsRead_,
|
markPrivateMessageRead as markGroupMsgAsRead_,
|
||||||
markGroupMessageRead as markPrivateMsgAsRead_,
|
markGroupMessageRead as markPrivateMsgAsRead_,
|
||||||
setFriendRemark as setFriendRemark_,
|
setFriendRemark as setFriendRemark_,
|
||||||
|
setGroupRemark as setGroupRemark_,
|
||||||
fetchGroupFileCount as fetchGroupFileCount_,
|
fetchGroupFileCount as fetchGroupFileCount_,
|
||||||
setOnlineStatus as setOnlineStatus_,
|
setOnlineStatus as setOnlineStatus_,
|
||||||
setProfile as setProfile_,
|
setProfile as setProfile_,
|
||||||
@@ -77,6 +81,8 @@ import {
|
|||||||
clickInlineKeyboardButton as clickInlineKeyboardButton_,
|
clickInlineKeyboardButton as clickInlineKeyboardButton_,
|
||||||
sendGroupSign as sendGroupSign_,
|
sendGroupSign as sendGroupSign_,
|
||||||
setAvatar as setAvatar_,
|
setAvatar as setAvatar_,
|
||||||
|
fetchCustomFace as fetchCustomFace_,
|
||||||
|
getEmojiLikes as getEmojiLikes_,
|
||||||
} from './bridge-actions';
|
} from './bridge-actions';
|
||||||
import {
|
import {
|
||||||
getGroupHonorInfo as getGroupHonorInfo_,
|
getGroupHonorInfo as getGroupHonorInfo_,
|
||||||
@@ -512,7 +518,10 @@ export class Bridge {
|
|||||||
|
|
||||||
async muteGroupMember(groupId: number, userId: number, duration: number): Promise<void> { return muteGroupMember_(this, groupId, userId, duration); }
|
async muteGroupMember(groupId: number, userId: number, duration: number): Promise<void> { return muteGroupMember_(this, groupId, userId, duration); }
|
||||||
async muteGroupAll(groupId: number, enable: boolean): Promise<void> { return muteGroupAll_(this, groupId, enable); }
|
async muteGroupAll(groupId: number, enable: boolean): Promise<void> { return muteGroupAll_(this, groupId, enable); }
|
||||||
|
async setGroupAddOption(groupId: number, addType: number): Promise<void> { return setGroupAddOption_(this, groupId, addType); }
|
||||||
|
async setGroupSearch(groupId: number): Promise<void> { return setGroupSearch_(this, groupId); }
|
||||||
async kickGroupMember(groupId: number, userId: number, reject: boolean, reason = ''): Promise<void> { return kickGroupMember_(this, groupId, userId, reject, reason); }
|
async kickGroupMember(groupId: number, userId: number, reject: boolean, reason = ''): Promise<void> { return kickGroupMember_(this, groupId, userId, reject, reason); }
|
||||||
|
async kickGroupMembers(groupId: number, userIds: number[], reject: boolean): Promise<void> { return kickGroupMembers_(this, groupId, userIds, reject); }
|
||||||
async leaveGroup(groupId: number): Promise<void> { return leaveGroup_(this, groupId); }
|
async leaveGroup(groupId: number): Promise<void> { return leaveGroup_(this, groupId); }
|
||||||
async setGroupAdmin(groupId: number, userId: number, enable: boolean): Promise<void> { return setGroupAdmin_(this, groupId, userId, enable); }
|
async setGroupAdmin(groupId: number, userId: number, enable: boolean): Promise<void> { return setGroupAdmin_(this, groupId, userId, enable); }
|
||||||
async setGroupCard(groupId: number, userId: number, card: string): Promise<void> { return setGroupCard_(this, groupId, userId, card); }
|
async setGroupCard(groupId: number, userId: number, card: string): Promise<void> { return setGroupCard_(this, groupId, userId, card); }
|
||||||
@@ -550,6 +559,7 @@ export class Bridge {
|
|||||||
async markGroupMsgAsRead(groupId: number, sequence: number): Promise<void> { return markGroupMsgAsRead_(this, groupId, sequence); }
|
async markGroupMsgAsRead(groupId: number, sequence: number): Promise<void> { return markGroupMsgAsRead_(this, groupId, sequence); }
|
||||||
async markPrivateMsgAsRead(userId: number, sequence: number): Promise<void> { return markPrivateMsgAsRead_(this, userId, sequence); }
|
async markPrivateMsgAsRead(userId: number, sequence: number): Promise<void> { return markPrivateMsgAsRead_(this, userId, sequence); }
|
||||||
async setFriendRemark(userId: number, remark: string): Promise<void> { return setFriendRemark_(this, userId, remark); }
|
async setFriendRemark(userId: number, remark: string): Promise<void> { return setFriendRemark_(this, userId, remark); }
|
||||||
|
async setGroupRemark(groupId: number, remark: string): Promise<void> { return setGroupRemark_(this, groupId, remark); }
|
||||||
async getGroupHonorInfo(groupId: number, type: WebHonorType | string): Promise<any> {
|
async getGroupHonorInfo(groupId: number, type: WebHonorType | string): Promise<any> {
|
||||||
return getGroupHonorInfo_(this, groupId, type);
|
return getGroupHonorInfo_(this, groupId, type);
|
||||||
}
|
}
|
||||||
@@ -616,6 +626,12 @@ export class Bridge {
|
|||||||
async setAvatar(source: string): Promise<void> {
|
async setAvatar(source: string): Promise<void> {
|
||||||
return setAvatar_(this, source);
|
return setAvatar_(this, source);
|
||||||
}
|
}
|
||||||
|
async fetchCustomFace(count?: number): Promise<string[]> {
|
||||||
|
return fetchCustomFace_(this, count);
|
||||||
|
}
|
||||||
|
async getEmojiLikes(groupId: number, sequence: number, emojiId: string, emojiType?: number, count?: number, cookie?: string) {
|
||||||
|
return getEmojiLikes_(this, groupId, sequence, emojiId, emojiType, count, cookie);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// --- Module-level helper functions ---
|
// --- Module-level helper functions ---
|
||||||
|
|||||||
@@ -28,6 +28,26 @@ export const OidbMuteAllSchema = {
|
|||||||
muteState: { field: 2, type: 'message' as const, schema: OidbMuteAllStateSchema },
|
muteState: { field: 2, type: 'message' as const, schema: OidbMuteAllStateSchema },
|
||||||
} satisfies ProtoSchema;
|
} satisfies ProtoSchema;
|
||||||
|
|
||||||
|
// --- 0x89A_0: Set group add option ---
|
||||||
|
|
||||||
|
export const Oidb0x89a_0AddOptionSettingsSchema = {
|
||||||
|
addType: { field: 16, type: 'uint32' as const },
|
||||||
|
} satisfies ProtoSchema;
|
||||||
|
|
||||||
|
export const Oidb0x89a_0AddOptionSchema = {
|
||||||
|
groupUin: { field: 1, type: 'uint64' as const },
|
||||||
|
settings: { field: 2, type: 'message' as const, schema: Oidb0x89a_0AddOptionSettingsSchema },
|
||||||
|
field12: { field: 12, type: 'uint32' as const },
|
||||||
|
} satisfies ProtoSchema;
|
||||||
|
|
||||||
|
// --- 0x89A_0: Set group search ---
|
||||||
|
|
||||||
|
export const Oidb0x89a_0SearchSchema = {
|
||||||
|
groupUin: { field: 1, type: 'uint64' as const },
|
||||||
|
settings: { field: 2, type: 'bytes' as const },
|
||||||
|
field12: { field: 12, type: 'uint32' as const },
|
||||||
|
} satisfies ProtoSchema;
|
||||||
|
|
||||||
// --- 0x8A0_1: Kick group member ---
|
// --- 0x8A0_1: Kick group member ---
|
||||||
|
|
||||||
export const OidbKickMemberSchema = {
|
export const OidbKickMemberSchema = {
|
||||||
@@ -1018,4 +1038,86 @@ export const Oidb0xeb7ReqSchema = {
|
|||||||
signInInfo: { field: 2, type: 'message' as const, schema: Oidb0xeb7SignInInfoSchema },
|
signInInfo: { field: 2, type: 'message' as const, schema: Oidb0xeb7SignInInfoSchema },
|
||||||
} satisfies ProtoSchema;
|
} satisfies ProtoSchema;
|
||||||
|
|
||||||
export const Oidb0xeb7RespSchema = {} satisfies ProtoSchema;
|
export const Oidb0xeb7RespSchema = {} satisfies ProtoSchema;
|
||||||
|
|
||||||
|
// --- Faceroam.OpReq: Fetch custom face ---
|
||||||
|
|
||||||
|
export const FaceroamOpReqInnerSchema = {
|
||||||
|
field1: { field: 1, type: 'uint32' as const },
|
||||||
|
osVersion: { field: 2, type: 'string' as const },
|
||||||
|
qqVersion: { field: 3, type: 'string' as const },
|
||||||
|
} satisfies ProtoSchema;
|
||||||
|
|
||||||
|
export const FaceroamOpReqSchema = {
|
||||||
|
inner: { field: 1, type: 'message' as const, schema: FaceroamOpReqInnerSchema },
|
||||||
|
uin: { field: 2, type: 'uint64' as const },
|
||||||
|
field3: { field: 3, type: 'uint32' as const },
|
||||||
|
field6: { field: 6, type: 'uint32' as const },
|
||||||
|
} satisfies ProtoSchema;
|
||||||
|
|
||||||
|
export const FaceroamOpRespItemSchema = {
|
||||||
|
faceIds: { field: 1, type: 'repeated_string' as const },
|
||||||
|
category: { field: 3, type: 'string' as const },
|
||||||
|
totalCount: { field: 4, type: 'uint32' as const },
|
||||||
|
} satisfies ProtoSchema;
|
||||||
|
|
||||||
|
export const FaceroamOpRespSchema = {
|
||||||
|
retCode: { field: 1, type: 'uint32' as const },
|
||||||
|
message: { field: 2, type: 'string' as const },
|
||||||
|
field3: { field: 3, type: 'uint32' as const },
|
||||||
|
item: { field: 4, type: 'message' as const, schema: FaceroamOpRespItemSchema },
|
||||||
|
} satisfies ProtoSchema;
|
||||||
|
|
||||||
|
// --- 0x9083_1: Get emoji likes ---
|
||||||
|
|
||||||
|
export const Oidb0x9083ReqSchema = {
|
||||||
|
groupId: { field: 2, type: 'uint64' as const },
|
||||||
|
sequence: { field: 3, type: 'uint32' as const },
|
||||||
|
emojiType: { field: 4, type: 'uint32' as const },
|
||||||
|
emojiId: { field: 5, type: 'string' as const },
|
||||||
|
cookie: { field: 6, type: 'bytes' as const },
|
||||||
|
field7: { field: 7, type: 'uint32' as const },
|
||||||
|
count: { field: 8, type: 'uint32' as const },
|
||||||
|
field12: { field: 12, type: 'uint32' as const },
|
||||||
|
} satisfies ProtoSchema;
|
||||||
|
|
||||||
|
export const Oidb0x9083RespUserInfoSchema = {
|
||||||
|
uin: { field: 1, type: 'uint64' as const },
|
||||||
|
field3: { field: 3, type: 'uint32' as const },
|
||||||
|
} satisfies ProtoSchema;
|
||||||
|
|
||||||
|
export const Oidb0x9083RespInnerSchema = {
|
||||||
|
userInfo: { field: 1, type: 'message' as const, schema: Oidb0x9083RespUserInfoSchema },
|
||||||
|
field4: { field: 4, type: 'uint32' as const },
|
||||||
|
} satisfies ProtoSchema;
|
||||||
|
|
||||||
|
export const Oidb0x9083RespSchema = {
|
||||||
|
inner: { field: 4, type: 'message' as const, schema: Oidb0x9083RespInnerSchema },
|
||||||
|
cookie: { field: 5, type: 'bytes' as const },
|
||||||
|
} satisfies ProtoSchema;
|
||||||
|
|
||||||
|
// --- 0x8a0_1: Kick group members (batch) ---
|
||||||
|
|
||||||
|
export const Oidb0x8a0ReqSchema = {
|
||||||
|
groupId: { field: 1, type: 'uint64' as const },
|
||||||
|
targetUids: { field: 3, type: 'repeated_string' as const },
|
||||||
|
rejectAddRequest: { field: 4, type: 'uint32' as const },
|
||||||
|
kickReason: { field: 5, type: 'bytes' as const },
|
||||||
|
field12: { field: 12, type: 'uint32' as const },
|
||||||
|
} satisfies ProtoSchema;
|
||||||
|
|
||||||
|
export const Oidb0x8a0RespSchema = {} satisfies ProtoSchema;
|
||||||
|
|
||||||
|
// --- 0xf16_1: Set group remark ---
|
||||||
|
|
||||||
|
export const Oidb0xf16InnerSchema = {
|
||||||
|
groupId: { field: 1, type: 'uint64' as const },
|
||||||
|
remark: { field: 3, type: 'string' as const },
|
||||||
|
} satisfies ProtoSchema;
|
||||||
|
|
||||||
|
export const Oidb0xf16ReqSchema = {
|
||||||
|
inner: { field: 1, type: 'message' as const, schema: Oidb0xf16InnerSchema },
|
||||||
|
field12: { field: 12, type: 'uint32' as const },
|
||||||
|
} satisfies ProtoSchema;
|
||||||
|
|
||||||
|
export const Oidb0xf16RespSchema = {} satisfies ProtoSchema;
|
||||||
@@ -494,6 +494,15 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
|||||||
return okResponse();
|
return okResponse();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
h.registerAction('set_group_remark', async (params) => {
|
||||||
|
const groupId = asNumber(params.group_id);
|
||||||
|
const remark = asString(params.remark) ?? '';
|
||||||
|
if (!groupId) return failedResponse(RETCODE.BAD_REQUEST, 'group_id is required');
|
||||||
|
if (!ctx.setGroupRemark) return failedResponse(RETCODE.ACTION_FAILED, 'not implemented');
|
||||||
|
await ctx.setGroupRemark(groupId, remark);
|
||||||
|
return okResponse();
|
||||||
|
});
|
||||||
|
|
||||||
h.registerAction('set_msg_emoji_like', async (params) => {
|
h.registerAction('set_msg_emoji_like', async (params) => {
|
||||||
const messageId = asNumber(params.message_id);
|
const messageId = asNumber(params.message_id);
|
||||||
const emojiId = asString(params.emoji_id);
|
const emojiId = asString(params.emoji_id);
|
||||||
@@ -644,6 +653,59 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
h.registerAction('fetch_custom_face', async (params) => {
|
||||||
|
const count = asNumber(params.count) || 10;
|
||||||
|
if (!ctx.fetchCustomFace) {
|
||||||
|
return failedResponse(RETCODE.ACTION_FAILED, 'not implemented');
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
const urls = await ctx.fetchCustomFace(count);
|
||||||
|
return okResponse(urls);
|
||||||
|
} catch (e) {
|
||||||
|
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
h.registerAction('get_emoji_likes', async (params) => {
|
||||||
|
const messageId = asNumber(params.message_id);
|
||||||
|
const emojiId = asString(params.emoji_id) || '';
|
||||||
|
if (!messageId || !emojiId) return failedResponse(RETCODE.BAD_REQUEST, 'message_id and emoji_id are required');
|
||||||
|
if (!ctx.getEmojiLikes) return failedResponse(RETCODE.ACTION_FAILED, 'not implemented');
|
||||||
|
try {
|
||||||
|
const meta = ctx.getMessageMeta(messageId);
|
||||||
|
if (!meta?.isGroup || !meta?.sequence) return failedResponse(RETCODE.BAD_REQUEST, 'message not found or not a group message');
|
||||||
|
const result = await ctx.getEmojiLikes(meta.targetId, meta.sequence, emojiId);
|
||||||
|
return okResponse({ emoji_like_list: result.users.map(u => ({ user_id: String(u.uin), nick_name: '' })) });
|
||||||
|
} catch (e) {
|
||||||
|
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
h.registerAction('fetch_emoji_like', async (params) => {
|
||||||
|
const messageId = asNumber(params.message_id);
|
||||||
|
const emojiId = asString(params.emojiId) || '';
|
||||||
|
const emojiType = asNumber(params.emojiType) || 1;
|
||||||
|
const count = asNumber(params.count) || 10;
|
||||||
|
const cookie = asString(params.cookie) || '';
|
||||||
|
if (!messageId || !emojiId) return failedResponse(RETCODE.BAD_REQUEST, 'message_id and emojiId are required');
|
||||||
|
if (!ctx.getEmojiLikes) return failedResponse(RETCODE.ACTION_FAILED, 'not implemented');
|
||||||
|
try {
|
||||||
|
const meta = ctx.getMessageMeta(messageId);
|
||||||
|
if (!meta?.isGroup || !meta?.sequence) return failedResponse(RETCODE.BAD_REQUEST, 'message not found or not a group message');
|
||||||
|
const result = await ctx.getEmojiLikes(meta.targetId, meta.sequence, emojiId, emojiType, count, cookie);
|
||||||
|
return okResponse({
|
||||||
|
result: 0,
|
||||||
|
errMsg: '',
|
||||||
|
emojiLikesList: result.users.map(u => ({ tinyId: String(u.uin), nickName: '', headUrl: '' })),
|
||||||
|
cookie: result.cookie,
|
||||||
|
isLastPage: result.isLast,
|
||||||
|
isFirstPage: !cookie,
|
||||||
|
});
|
||||||
|
} catch (e) {
|
||||||
|
return failedResponse(RETCODE.ACTION_FAILED, String(e));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
h.registerAction('get_friends_with_category', async () => {
|
h.registerAction('get_friends_with_category', async () => {
|
||||||
if (ctx.getFriendList) {
|
if (ctx.getFriendList) {
|
||||||
return okResponse(await ctx.getFriendList());
|
return okResponse(await ctx.getFriendList());
|
||||||
|
|||||||
@@ -13,6 +13,16 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
|||||||
return okResponse();
|
return okResponse();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
h.registerAction('set_group_kick_members', async (params) => {
|
||||||
|
const groupId = asNumber(params.group_id);
|
||||||
|
const userIds = Array.isArray(params.user_id) ? params.user_id.map(asNumber).filter(Boolean) : [];
|
||||||
|
const reject = asBoolean(params.reject_add_request, false);
|
||||||
|
if (!groupId || userIds.length === 0) return failedResponse(RETCODE.BAD_REQUEST, 'group_id and user_id array are required');
|
||||||
|
if (!ctx.setGroupKickMembers) return failedResponse(RETCODE.ACTION_FAILED, 'not implemented');
|
||||||
|
await ctx.setGroupKickMembers(groupId, userIds, reject);
|
||||||
|
return okResponse();
|
||||||
|
});
|
||||||
|
|
||||||
h.registerAction('set_group_ban', async (params) => {
|
h.registerAction('set_group_ban', async (params) => {
|
||||||
const groupId = asNumber(params.group_id);
|
const groupId = asNumber(params.group_id);
|
||||||
const userId = asNumber(params.user_id);
|
const userId = asNumber(params.user_id);
|
||||||
@@ -32,6 +42,23 @@ export function register(h: ApiHandler, ctx: ApiActionContext): void {
|
|||||||
return okResponse();
|
return okResponse();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
h.registerAction('set_group_add_option', async (params) => {
|
||||||
|
const groupId = asNumber(params.group_id);
|
||||||
|
const addType = asNumber(params.add_type);
|
||||||
|
if (!groupId || addType === undefined) return failedResponse(RETCODE.BAD_REQUEST, 'group_id and add_type are required');
|
||||||
|
if (!ctx.setGroupAddOption) return failedResponse(RETCODE.ACTION_FAILED, 'not implemented');
|
||||||
|
await ctx.setGroupAddOption(groupId, addType);
|
||||||
|
return okResponse();
|
||||||
|
});
|
||||||
|
|
||||||
|
h.registerAction('set_group_search', async (params) => {
|
||||||
|
const groupId = asNumber(params.group_id);
|
||||||
|
if (!groupId) return failedResponse(RETCODE.BAD_REQUEST, 'group_id is required');
|
||||||
|
if (!ctx.setGroupSearch) return failedResponse(RETCODE.ACTION_FAILED, 'not implemented');
|
||||||
|
await ctx.setGroupSearch(groupId);
|
||||||
|
return okResponse();
|
||||||
|
});
|
||||||
|
|
||||||
h.registerAction('set_group_admin', async (params) => {
|
h.registerAction('set_group_admin', async (params) => {
|
||||||
const groupId = asNumber(params.group_id);
|
const groupId = asNumber(params.group_id);
|
||||||
const userId = asNumber(params.user_id);
|
const userId = asNumber(params.user_id);
|
||||||
|
|||||||
@@ -48,8 +48,11 @@ export interface ApiActionContext {
|
|||||||
getStrangerInfo?: (userId: number) => Promise<JsonObject | null>;
|
getStrangerInfo?: (userId: number) => Promise<JsonObject | null>;
|
||||||
// Group admin
|
// Group admin
|
||||||
setGroupKick?: (groupId: number, userId: number, rejectAdd: boolean) => Promise<void>;
|
setGroupKick?: (groupId: number, userId: number, rejectAdd: boolean) => Promise<void>;
|
||||||
|
setGroupKickMembers?: (groupId: number, userIds: number[], rejectAdd: boolean) => Promise<void>;
|
||||||
setGroupBan?: (groupId: number, userId: number, duration: number) => Promise<void>;
|
setGroupBan?: (groupId: number, userId: number, duration: number) => Promise<void>;
|
||||||
setGroupWholeBan?: (groupId: number, enable: boolean) => Promise<void>;
|
setGroupWholeBan?: (groupId: number, enable: boolean) => Promise<void>;
|
||||||
|
setGroupAddOption?: (groupId: number, addType: number) => Promise<void>;
|
||||||
|
setGroupSearch?: (groupId: number) => Promise<void>;
|
||||||
setGroupAdmin?: (groupId: number, userId: number, enable: boolean) => Promise<void>;
|
setGroupAdmin?: (groupId: number, userId: number, enable: boolean) => Promise<void>;
|
||||||
setGroupCard?: (groupId: number, userId: number, card: string) => Promise<void>;
|
setGroupCard?: (groupId: number, userId: number, card: string) => Promise<void>;
|
||||||
setGroupName?: (groupId: number, name: string) => Promise<void>;
|
setGroupName?: (groupId: number, name: string) => Promise<void>;
|
||||||
@@ -100,11 +103,14 @@ export interface ApiActionContext {
|
|||||||
getForwardMsg?: (resId: string) => Promise<JsonObject[]>;
|
getForwardMsg?: (resId: string) => Promise<JsonObject[]>;
|
||||||
// Extended NapCat-compatible
|
// Extended NapCat-compatible
|
||||||
setFriendRemark?: (userId: number, remark: string) => Promise<void>;
|
setFriendRemark?: (userId: number, remark: string) => Promise<void>;
|
||||||
|
setGroupRemark?: (groupId: number, remark: string) => Promise<void>;
|
||||||
getGroupFileCount?: (groupId: number) => Promise<{ fileCount: number; maxCount: number }>;
|
getGroupFileCount?: (groupId: number) => Promise<{ fileCount: number; maxCount: number }>;
|
||||||
setMsgEmojiLike?: (messageId: number, emojiId: string, set: boolean) => Promise<void>;
|
setMsgEmojiLike?: (messageId: number, emojiId: string, set: boolean) => Promise<void>;
|
||||||
markGroupMsgAsRead?: (groupId: number, sequence: number) => Promise<void>;
|
markGroupMsgAsRead?: (groupId: number, sequence: number) => Promise<void>;
|
||||||
markPrivateMsgAsRead?: (userId: number, sequence: number) => Promise<void>;
|
markPrivateMsgAsRead?: (userId: number, sequence: number) => Promise<void>;
|
||||||
getProfileLike?: (userId?: number, start?: number, limit?: number) => Promise<any>;
|
getProfileLike?: (userId?: number, start?: number, limit?: number) => Promise<any>;
|
||||||
|
fetchCustomFace?: (count?: number) => Promise<string[]>;
|
||||||
|
getEmojiLikes?: (groupId: number, sequence: number, emojiId: string, emojiType?: number, count?: number, cookie?: string) => Promise<{ users: Array<{ uin: number }>, cookie: string, isLast: boolean }>;
|
||||||
// Web
|
// Web
|
||||||
getGroupHonorInfo?: (groupId: number, type: WebHonorType | string) => Promise<any>;
|
getGroupHonorInfo?: (groupId: number, type: WebHonorType | string) => Promise<any>;
|
||||||
getGroupEssence?: (groupId: number, pageStart?: number, pageLimit?: number) => Promise<GroupEssenceMsgRet>;
|
getGroupEssence?: (groupId: number, pageStart?: number, pageLimit?: number) => Promise<GroupEssenceMsgRet>;
|
||||||
|
|||||||
@@ -72,8 +72,11 @@ export function buildApiContext(ref: OneBotInstanceContext): ApiActionContext {
|
|||||||
getStrangerInfo: (userId) => handleGetStrangerInfo(bridge, qqInfo, userId),
|
getStrangerInfo: (userId) => handleGetStrangerInfo(bridge, qqInfo, userId),
|
||||||
// Group admin
|
// Group admin
|
||||||
setGroupKick: (groupId, userId, reject) => bridge.kickGroupMember(groupId, userId, reject),
|
setGroupKick: (groupId, userId, reject) => bridge.kickGroupMember(groupId, userId, reject),
|
||||||
|
setGroupKickMembers: (groupId, userIds, reject) => bridge.kickGroupMembers(groupId, userIds, reject),
|
||||||
setGroupBan: (groupId, userId, duration) => bridge.muteGroupMember(groupId, userId, duration),
|
setGroupBan: (groupId, userId, duration) => bridge.muteGroupMember(groupId, userId, duration),
|
||||||
setGroupWholeBan: (groupId, enable) => bridge.muteGroupAll(groupId, enable),
|
setGroupWholeBan: (groupId, enable) => bridge.muteGroupAll(groupId, enable),
|
||||||
|
setGroupAddOption: (groupId, addType) => bridge.setGroupAddOption(groupId, addType),
|
||||||
|
setGroupSearch: (groupId) => bridge.setGroupSearch(groupId),
|
||||||
setGroupAdmin: (groupId, userId, enable) => bridge.setGroupAdmin(groupId, userId, enable),
|
setGroupAdmin: (groupId, userId, enable) => bridge.setGroupAdmin(groupId, userId, enable),
|
||||||
setGroupCard: (groupId, userId, card) => bridge.setGroupCard(groupId, userId, card),
|
setGroupCard: (groupId, userId, card) => bridge.setGroupCard(groupId, userId, card),
|
||||||
setGroupName: (groupId, name) => bridge.setGroupName(groupId, name),
|
setGroupName: (groupId, name) => bridge.setGroupName(groupId, name),
|
||||||
@@ -107,6 +110,8 @@ export function buildApiContext(ref: OneBotInstanceContext): ApiActionContext {
|
|||||||
setEssenceMsg: (messageId) => handleSetEssence(bridge, messageStore, messageId, true),
|
setEssenceMsg: (messageId) => handleSetEssence(bridge, messageStore, messageId, true),
|
||||||
deleteEssenceMsg: (messageId) => handleSetEssence(bridge, messageStore, messageId, false),
|
deleteEssenceMsg: (messageId) => handleSetEssence(bridge, messageStore, messageId, false),
|
||||||
getProfileLike: (userId?: number, start: number = 0, limit: number = 10) => bridge.getProfileLike(userId, start, limit),
|
getProfileLike: (userId?: number, start: number = 0, limit: number = 10) => bridge.getProfileLike(userId, start, limit),
|
||||||
|
fetchCustomFace: (count?: number) => bridge.fetchCustomFace(count),
|
||||||
|
getEmojiLikes: (groupId, sequence, emojiId, emojiType, count, cookie) => bridge.getEmojiLikes(groupId, sequence, emojiId, emojiType, count, cookie),
|
||||||
getUnidirectionalFriendList: () => bridge.getUnidirectionalFriendList(),
|
getUnidirectionalFriendList: () => bridge.getUnidirectionalFriendList(),
|
||||||
setSelfLongNick: (longNick) => bridge.setSelfLongNick(longNick),
|
setSelfLongNick: (longNick) => bridge.setSelfLongNick(longNick),
|
||||||
setInputStatus: (userId, eventType) => bridge.setInputStatus(userId, eventType),
|
setInputStatus: (userId, eventType) => bridge.setInputStatus(userId, eventType),
|
||||||
@@ -154,6 +159,7 @@ export function buildApiContext(ref: OneBotInstanceContext): ApiActionContext {
|
|||||||
|
|
||||||
// Extended NapCat-compatible
|
// Extended NapCat-compatible
|
||||||
setFriendRemark: (userId, remark) => bridge.setFriendRemark(userId, remark),
|
setFriendRemark: (userId, remark) => bridge.setFriendRemark(userId, remark),
|
||||||
|
setGroupRemark: (groupId, remark) => bridge.setGroupRemark(groupId, remark),
|
||||||
getGroupFileCount: (groupId) => bridge.fetchGroupFileCount(groupId),
|
getGroupFileCount: (groupId) => bridge.fetchGroupFileCount(groupId),
|
||||||
setMsgEmojiLike: async (messageId, emojiId, set) => {
|
setMsgEmojiLike: async (messageId, emojiId, set) => {
|
||||||
const meta = messageStore.findMeta(messageId);
|
const meta = messageStore.findMeta(messageId);
|
||||||
|
|||||||
Reference in new issue
Block a user