feat: add get_group_share_link action (NTQQ getJoinGroupLink) (#2041)
This commit is contained in:
4 files changed
+63
No files matched your search
@@ -351,6 +351,15 @@ export class NTQQGroupApi {
|
|||||||
return this.context.session.getGroupService().getGroupRecommendContactArkJson(groupCode);
|
return this.context.session.getGroupService().getGroupRecommendContactArkJson(groupCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async getJoinGroupLink (groupCode: string, needShortUrl = true, srcId = 73, additionalParam = '') {
|
||||||
|
return this.context.session.getGroupService().getJoinGroupLink({
|
||||||
|
groupCode,
|
||||||
|
srcId,
|
||||||
|
needShortUrl,
|
||||||
|
additionalParam,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
async creatGroupFileFolder (groupCode: string, folderName: string) {
|
async creatGroupFileFolder (groupCode: string, folderName: string) {
|
||||||
return this.context.session.getRichMediaService().createGroupFolder(groupCode, folderName);
|
return this.context.session.getRichMediaService().createGroupFolder(groupCode, folderName);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,51 @@
|
|||||||
|
import { OneBotAction } from '@/napcat-onebot/action/OneBotAction';
|
||||||
|
import { ActionName } from '@/napcat-onebot/action/router';
|
||||||
|
import { Type, Static } from '@sinclair/typebox';
|
||||||
|
|
||||||
|
const PayloadSchema = Type.Object({
|
||||||
|
group_id: Type.Union([Type.Number(), Type.String()], { description: '群号' }),
|
||||||
|
need_short_url: Type.Optional(Type.Union([Type.Boolean(), Type.String()], { default: true, description: '是否返回短链 (qm.qq.com/q/xxx),false 返回完整 universal-share 链接' })),
|
||||||
|
src_id: Type.Optional(Type.Union([Type.Number(), Type.String()], { default: 73, description: '分享来源 ID' })),
|
||||||
|
additional_param: Type.Optional(Type.String({ default: '', description: '附加参数' })),
|
||||||
|
});
|
||||||
|
|
||||||
|
type PayloadType = Static<typeof PayloadSchema>;
|
||||||
|
|
||||||
|
const ReturnSchema = Type.Object({
|
||||||
|
url: Type.String({ description: '群分享链接' }),
|
||||||
|
}, { description: '群分享链接' });
|
||||||
|
|
||||||
|
type ReturnType = Static<typeof ReturnSchema>;
|
||||||
|
|
||||||
|
export class GetGroupShareLink extends OneBotAction<PayloadType, ReturnType> {
|
||||||
|
override actionName = ActionName.GetGroupShareLink;
|
||||||
|
override actionSummary = '获取群分享链接';
|
||||||
|
override actionDescription = '通过 NTQQ 原生 getJoinGroupLink 获取群的 H5 分享/加群链接 (qm.qq.com/q/xxx 或 qun.qq.com/universal-share/share?...)';
|
||||||
|
override actionTags = ['群组扩展'];
|
||||||
|
override payloadExample = {
|
||||||
|
group_id: '123456',
|
||||||
|
need_short_url: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
override returnExample = {
|
||||||
|
url: 'https://qm.qq.com/q/xxxxxxxxxx',
|
||||||
|
};
|
||||||
|
|
||||||
|
override payloadSchema = PayloadSchema;
|
||||||
|
override returnSchema = ReturnSchema;
|
||||||
|
|
||||||
|
async _handle (payload: PayloadType) {
|
||||||
|
const needShortUrl = payload.need_short_url === undefined ? true : payload.need_short_url.toString() === 'true';
|
||||||
|
const srcId = payload.src_id === undefined ? 73 : Number(payload.src_id);
|
||||||
|
const ret = await this.core.apis.GroupApi.getJoinGroupLink(
|
||||||
|
payload.group_id.toString(),
|
||||||
|
needShortUrl,
|
||||||
|
srcId,
|
||||||
|
payload.additional_param ?? ''
|
||||||
|
);
|
||||||
|
if (!ret?.url) {
|
||||||
|
throw new Error(`获取群分享链接失败: ${ret?.errMsg || JSON.stringify(ret)}`);
|
||||||
|
}
|
||||||
|
return { url: ret.url };
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -75,6 +75,7 @@ import { SetInputStatus } from './extends/SetInputStatus';
|
|||||||
import { GetCSRF } from './system/GetCSRF';
|
import { GetCSRF } from './system/GetCSRF';
|
||||||
import { DelGroupNotice } from './group/DelGroupNotice';
|
import { DelGroupNotice } from './group/DelGroupNotice';
|
||||||
import { GetGroupInfoEx } from './extends/GetGroupInfoEx';
|
import { GetGroupInfoEx } from './extends/GetGroupInfoEx';
|
||||||
|
import { GetGroupShareLink } from './extends/GetGroupShareLink';
|
||||||
import { DeleteGroupFile } from '@/napcat-onebot/action/go-cqhttp/DeleteGroupFile';
|
import { DeleteGroupFile } from '@/napcat-onebot/action/go-cqhttp/DeleteGroupFile';
|
||||||
import { CreateGroupFileFolder } from '@/napcat-onebot/action/go-cqhttp/CreateGroupFileFolder';
|
import { CreateGroupFileFolder } from '@/napcat-onebot/action/go-cqhttp/CreateGroupFileFolder';
|
||||||
import { DeleteGroupFileFolder } from '@/napcat-onebot/action/go-cqhttp/DeleteGroupFileFolder';
|
import { DeleteGroupFileFolder } from '@/napcat-onebot/action/go-cqhttp/DeleteGroupFileFolder';
|
||||||
@@ -196,6 +197,7 @@ export function getAllHandlers (obContext: NapCatOneBot11Adapter, core: NapCatCo
|
|||||||
new GetRkeyServer(obContext, core),
|
new GetRkeyServer(obContext, core),
|
||||||
new SetGroupRemark(obContext, core),
|
new SetGroupRemark(obContext, core),
|
||||||
new GetGroupInfoEx(obContext, core),
|
new GetGroupInfoEx(obContext, core),
|
||||||
|
new GetGroupShareLink(obContext, core),
|
||||||
new FetchEmojiLike(obContext, core),
|
new FetchEmojiLike(obContext, core),
|
||||||
new GetEmojiLikes(obContext, core),
|
new GetEmojiLikes(obContext, core),
|
||||||
new FetchPttText(obContext, core),
|
new FetchPttText(obContext, core),
|
||||||
|
|||||||
@@ -166,6 +166,7 @@ export const ActionName = {
|
|||||||
GetEmojiLikes: 'get_emoji_likes',
|
GetEmojiLikes: 'get_emoji_likes',
|
||||||
SetInputStatus: 'set_input_status',
|
SetInputStatus: 'set_input_status',
|
||||||
GetGroupInfoEx: 'get_group_info_ex',
|
GetGroupInfoEx: 'get_group_info_ex',
|
||||||
|
GetGroupShareLink: 'get_group_share_link',
|
||||||
GetGroupDetailInfo: 'get_group_detail_info',
|
GetGroupDetailInfo: 'get_group_detail_info',
|
||||||
GetGroupIgnoreAddRequest: 'get_group_ignore_add_request',
|
GetGroupIgnoreAddRequest: 'get_group_ignore_add_request',
|
||||||
DelGroupNotice: '_del_group_notice',
|
DelGroupNotice: '_del_group_notice',
|
||||||
|
|||||||
Reference in new issue
Block a user