feat: 新增群荣誉信息

This commit is contained in:
手瓜一十雪 2024-05-14 14:02:29 +08:00
parent 5649ff9c2e
commit b4b91af02b
5 changed files with 46 additions and 19 deletions

View File

@ -8,5 +8,6 @@ QQ Version: Windows 9.9.9-23424 / Linux 3.2.7-23361
## 新增与调整
* 修复快速重启进程清理问题
* 支持WebUi热重载
* 新增群荣誉信息 /get_group_honor_info
新增的 API 详细见[API文档](https://napneko.github.io/zh-CN/develop/extends_api)

View File

@ -1,23 +1,31 @@
import { get as httpsGet } from 'https';
export class RequestUtil {
//适用于获取服务器下发cookies时获取
static async HttpGetCookies(url: string, method: string = 'GET'): Promise<Map<string, string>> {
const response = await fetch(url, { method: method });
if (!response.ok) {
throw new Error(`Failed to fetch: ${response.statusText}`);
}
const cookiesHeader = response.headers.get('set-cookie');
if (!cookiesHeader) {
return new Map<string, string>();
}
const result = new Map<string, string>();
cookiesHeader.split(';').forEach((cookieLine) => {
const [key, value] = cookieLine.split('=');
result.set(key.trim(), value.trim());
//适用于获取服务器下发cookies时获取 仅get
static async HttpsGetCookies(url: string): Promise<Map<string, string>> {
return new Promise((resolve, reject) => {
const result: Map<string, string> = new Map<string, string>();
const req = httpsGet(url, (res: any) => {
res.on('data', (data: any) => {
});
res.on('end', () => {
try {
const responseCookies = res.headers['set-cookie'];
for (const line of responseCookies) {
const parts = line.split(';');
const [key, value] = parts[0].split('=');
result.set(key, value);
}
} catch (e) {
}
resolve(result);
});
});
req.on('error', (error: any) => {
resolve(result);
// console.log(error)
});
req.end();
});
return result;
}
// 请求和回复都是JSON data传原始内容 自动编码json
static async HttpGetJson<T>(url: string, method: string = 'GET', data?: any, headers: Record<string, string> = {}):

@ -1 +1 @@
Subproject commit 5360d70991c87394f205a4cf9f54ad1bd74fefbf
Subproject commit c30a351bbb9046c31b471e9a818d7b28f971541a

View File

@ -0,0 +1,17 @@
import { OB11User } from '../../types';
import { OB11Constructor } from '../../constructor';
import { friends } from '@/core/data';
import BaseAction from '../BaseAction';
import { ActionName } from '../types';
import { NTQQUserApi, WebApi } from '@/core/apis';
interface Payload {
groud_id: string
}
export class GetGroupHonorInfo extends BaseAction<Payload, Array<any>> {
actionName = ActionName.GetGroupHonorInfo;
protected async _handle(payload: Payload) {
// console.log(await NTQQUserApi.getRobotUinRange());
return await WebApi.getGroupHonorInfo(payload.groud_id);
}
}

View File

@ -60,6 +60,7 @@ export enum ActionName {
CleanCache = 'clean_cache',
GetCookies = 'get_cookies',
// 以下为go-cqhttp api
GetGroupHonorInfo = 'get_group_honor_info',
GoCQHTTP_GetEssenceMsg = 'get_essence_msg_list',
GoCQHTTP_SendGroupNotice = '_send_group_notice',
GoCQHTTP_GetGroupNotice = '_get_group_notice',