mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
feat: 新增群荣誉信息
This commit is contained in:
parent
5649ff9c2e
commit
b4b91af02b
@ -8,5 +8,6 @@ QQ Version: Windows 9.9.9-23424 / Linux 3.2.7-23361
|
|||||||
## 新增与调整
|
## 新增与调整
|
||||||
* 修复快速重启进程清理问题
|
* 修复快速重启进程清理问题
|
||||||
* 支持WebUi热重载
|
* 支持WebUi热重载
|
||||||
|
* 新增群荣誉信息 /get_group_honor_info
|
||||||
|
|
||||||
新增的 API 详细见[API文档](https://napneko.github.io/zh-CN/develop/extends_api)
|
新增的 API 详细见[API文档](https://napneko.github.io/zh-CN/develop/extends_api)
|
||||||
|
@ -1,23 +1,31 @@
|
|||||||
|
import { get as httpsGet } from 'https';
|
||||||
export class RequestUtil {
|
export class RequestUtil {
|
||||||
//适用于获取服务器下发cookies时获取
|
//适用于获取服务器下发cookies时获取 仅get
|
||||||
static async HttpGetCookies(url: string, method: string = 'GET'): Promise<Map<string, string>> {
|
static async HttpsGetCookies(url: string): Promise<Map<string, string>> {
|
||||||
const response = await fetch(url, { method: method });
|
return new Promise((resolve, reject) => {
|
||||||
if (!response.ok) {
|
const result: Map<string, string> = new Map<string, string>();
|
||||||
throw new Error(`Failed to fetch: ${response.statusText}`);
|
const req = httpsGet(url, (res: any) => {
|
||||||
}
|
res.on('data', (data: any) => {
|
||||||
|
});
|
||||||
const cookiesHeader = response.headers.get('set-cookie');
|
res.on('end', () => {
|
||||||
if (!cookiesHeader) {
|
try {
|
||||||
return new Map<string, string>();
|
const responseCookies = res.headers['set-cookie'];
|
||||||
}
|
for (const line of responseCookies) {
|
||||||
|
const parts = line.split(';');
|
||||||
const result = new Map<string, string>();
|
const [key, value] = parts[0].split('=');
|
||||||
cookiesHeader.split(';').forEach((cookieLine) => {
|
result.set(key, value);
|
||||||
const [key, value] = cookieLine.split('=');
|
}
|
||||||
result.set(key.trim(), value.trim());
|
} catch (e) {
|
||||||
|
}
|
||||||
|
resolve(result);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
req.on('error', (error: any) => {
|
||||||
|
resolve(result);
|
||||||
|
// console.log(error)
|
||||||
|
});
|
||||||
|
req.end();
|
||||||
});
|
});
|
||||||
|
|
||||||
return result;
|
|
||||||
}
|
}
|
||||||
// 请求和回复都是JSON data传原始内容 自动编码json
|
// 请求和回复都是JSON data传原始内容 自动编码json
|
||||||
static async HttpGetJson<T>(url: string, method: string = 'GET', data?: any, headers: Record<string, string> = {}):
|
static async HttpGetJson<T>(url: string, method: string = 'GET', data?: any, headers: Record<string, string> = {}):
|
||||||
|
2
src/core
2
src/core
@ -1 +1 @@
|
|||||||
Subproject commit 5360d70991c87394f205a4cf9f54ad1bd74fefbf
|
Subproject commit c30a351bbb9046c31b471e9a818d7b28f971541a
|
17
src/onebot11/action/extends/GetGroupHonorInfo.ts
Normal file
17
src/onebot11/action/extends/GetGroupHonorInfo.ts
Normal 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);
|
||||||
|
}
|
||||||
|
}
|
@ -60,6 +60,7 @@ export enum ActionName {
|
|||||||
CleanCache = 'clean_cache',
|
CleanCache = 'clean_cache',
|
||||||
GetCookies = 'get_cookies',
|
GetCookies = 'get_cookies',
|
||||||
// 以下为go-cqhttp api
|
// 以下为go-cqhttp api
|
||||||
|
GetGroupHonorInfo = 'get_group_honor_info',
|
||||||
GoCQHTTP_GetEssenceMsg = 'get_essence_msg_list',
|
GoCQHTTP_GetEssenceMsg = 'get_essence_msg_list',
|
||||||
GoCQHTTP_SendGroupNotice = '_send_group_notice',
|
GoCQHTTP_SendGroupNotice = '_send_group_notice',
|
||||||
GoCQHTTP_GetGroupNotice = '_get_group_notice',
|
GoCQHTTP_GetGroupNotice = '_get_group_notice',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user