mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
feat: webapi
This commit is contained in:
@@ -4,6 +4,7 @@ import { NTQQGroupApi } from '../ntqqapi/api/group'
|
|||||||
import { log } from './utils/log'
|
import { log } from './utils/log'
|
||||||
import { isNumeric } from './utils/helper'
|
import { isNumeric } from './utils/helper'
|
||||||
import { NTQQFriendApi } from '../ntqqapi/api'
|
import { NTQQFriendApi } from '../ntqqapi/api'
|
||||||
|
import { WebApiGroupMember } from '@/ntqqapi/api/webapi'
|
||||||
|
|
||||||
export const selfInfo: SelfInfo = {
|
export const selfInfo: SelfInfo = {
|
||||||
uid: '',
|
uid: '',
|
||||||
@@ -11,6 +12,10 @@ export const selfInfo: SelfInfo = {
|
|||||||
nick: '',
|
nick: '',
|
||||||
online: true,
|
online: true,
|
||||||
}
|
}
|
||||||
|
export const WebGroupData = {
|
||||||
|
GroupData: new Map<string, Array<WebApiGroupMember>>(),
|
||||||
|
GroupTime: new Map<string, number>()
|
||||||
|
};
|
||||||
export let groups: Group[] = []
|
export let groups: Group[] = []
|
||||||
export let friends: Friend[] = []
|
export let friends: Friend[] = []
|
||||||
export let friendRequests: Map<number, FriendRequest> = new Map<number, FriendRequest>()
|
export let friendRequests: Map<number, FriendRequest> = new Map<number, FriendRequest>()
|
||||||
|
87
src/common/utils/request.ts
Normal file
87
src/common/utils/request.ts
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
import https from 'node:https';
|
||||||
|
import http from 'node:http';
|
||||||
|
|
||||||
|
export class RequestUtil {
|
||||||
|
// 适用于获取服务器下发cookies时获取,仅GET
|
||||||
|
static async HttpsGetCookies(url: string): Promise<Map<string, string>> {
|
||||||
|
return new Promise<Map<string, string>>((resolve, reject) => {
|
||||||
|
const protocol = url.startsWith('https://') ? https : http;
|
||||||
|
protocol.get(url, (res) => {
|
||||||
|
const cookiesHeader = res.headers['set-cookie'];
|
||||||
|
if (!cookiesHeader) {
|
||||||
|
resolve(new Map<string, string>());
|
||||||
|
} else {
|
||||||
|
const cookiesMap = new Map<string, string>();
|
||||||
|
cookiesHeader.forEach((cookieStr) => {
|
||||||
|
cookieStr.split(';').forEach((cookiePart) => {
|
||||||
|
const trimmedPart = cookiePart.trim();
|
||||||
|
if (trimmedPart.includes('=')) {
|
||||||
|
const [key, value] = trimmedPart.split('=').map(part => part.trim());
|
||||||
|
cookiesMap.set(key, decodeURIComponent(value)); // 解码cookie值
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
resolve(cookiesMap);
|
||||||
|
}
|
||||||
|
}).on('error', (error) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 请求和回复都是JSON data传原始内容 自动编码json
|
||||||
|
static async HttpGetJson<T>(url: string, method: string = 'GET', data?: any, headers: Record<string, string> = {}, isJsonRet: boolean = true, isArgJson: boolean = true): Promise<T> {
|
||||||
|
let option = new URL(url);
|
||||||
|
const protocol = url.startsWith('https://') ? https : http;
|
||||||
|
const options = {
|
||||||
|
hostname: option.hostname,
|
||||||
|
port: option.port,
|
||||||
|
path: option.href,
|
||||||
|
method: method,
|
||||||
|
headers: headers
|
||||||
|
};
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const req = protocol.request(options, (res: any) => {
|
||||||
|
let responseBody = '';
|
||||||
|
res.on('data', (chunk: string | Buffer) => {
|
||||||
|
responseBody += chunk.toString();
|
||||||
|
});
|
||||||
|
|
||||||
|
res.on('end', () => {
|
||||||
|
try {
|
||||||
|
if (res.statusCode && res.statusCode >= 200 && res.statusCode < 300) {
|
||||||
|
if (isJsonRet) {
|
||||||
|
const responseJson = JSON.parse(responseBody);
|
||||||
|
resolve(responseJson as T);
|
||||||
|
} else {
|
||||||
|
resolve(responseBody as T);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
reject(new Error(`Unexpected status code: ${res.statusCode}`));
|
||||||
|
}
|
||||||
|
} catch (parseError) {
|
||||||
|
reject(parseError);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
req.on('error', (error: any) => {
|
||||||
|
reject(error);
|
||||||
|
});
|
||||||
|
if (method === 'POST' || method === 'PUT' || method === 'PATCH') {
|
||||||
|
if (isArgJson) {
|
||||||
|
req.write(JSON.stringify(data));
|
||||||
|
} else {
|
||||||
|
req.write(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
req.end();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
// 请求返回都是原始内容
|
||||||
|
static async HttpGetText(url: string, method: string = 'GET', data?: any, headers: Record<string, string> = {}) {
|
||||||
|
return this.HttpGetJson<string>(url, method, data, headers, false, false);
|
||||||
|
}
|
||||||
|
}
|
@@ -1,76 +1,379 @@
|
|||||||
import { groups } from '../../common/data'
|
import { WebGroupData, groups, selfInfo } from '@/common/data';
|
||||||
import { log } from '../../common/utils'
|
import { log } from '@/common/utils/log';
|
||||||
import { NTQQUserApi } from './user'
|
import { NTQQUserApi } from './user';
|
||||||
|
import { RequestUtil } from '@/common/utils/request';
|
||||||
export class WebApi {
|
export enum WebHonorType {
|
||||||
private static bkn: string
|
ALL = 'all',
|
||||||
private static skey: string
|
TALKACTIVE = 'talkative',
|
||||||
private static pskey: string
|
PERFROMER = 'performer',
|
||||||
private static cookie: string
|
LEGEND = 'legend',
|
||||||
private defaultHeaders: Record<string, string> = {
|
STORONGE_NEWBI = 'strong_newbie',
|
||||||
'User-Agent': 'QQ/8.9.28.635 CFNetwork/1312 Darwin/21.0.0',
|
EMOTION = 'emotion'
|
||||||
|
}
|
||||||
|
export interface WebApiGroupMember {
|
||||||
|
uin: number
|
||||||
|
role: number
|
||||||
|
g: number
|
||||||
|
join_time: number
|
||||||
|
last_speak_time: number
|
||||||
|
lv: {
|
||||||
|
point: number
|
||||||
|
level: number
|
||||||
}
|
}
|
||||||
|
card: string
|
||||||
constructor() {}
|
tags: string
|
||||||
|
flag: number
|
||||||
public async addGroupDigest(groupCode: string, msgSeq: string) {
|
nick: string
|
||||||
const url = `https://qun.qq.com/cgi-bin/group_digest/cancel_digest?random=665&X-CROSS-ORIGIN=fetch&group_code=${groupCode}&msg_seq=${msgSeq}&msg_random=444021292`
|
qage: number
|
||||||
const res = await this.request(url)
|
rm: number
|
||||||
return await res.json()
|
}
|
||||||
|
interface WebApiGroupMemberRet {
|
||||||
|
ec: number
|
||||||
|
errcode: number
|
||||||
|
em: string
|
||||||
|
cache: number
|
||||||
|
adm_num: number
|
||||||
|
levelname: any
|
||||||
|
mems: WebApiGroupMember[]
|
||||||
|
count: number
|
||||||
|
svr_time: number
|
||||||
|
max_count: number
|
||||||
|
search_count: number
|
||||||
|
extmode: number
|
||||||
|
}
|
||||||
|
export interface WebApiGroupNoticeFeed {
|
||||||
|
u: number//发送者
|
||||||
|
fid: string//fid
|
||||||
|
pubt: number//时间
|
||||||
|
msg: {
|
||||||
|
text: string
|
||||||
|
text_face: string
|
||||||
|
title: string,
|
||||||
|
pics?: {
|
||||||
|
id: string,
|
||||||
|
w: string,
|
||||||
|
h: string
|
||||||
|
}[]
|
||||||
}
|
}
|
||||||
|
type: number
|
||||||
public async getGroupDigest(groupCode: string) {
|
fn: number
|
||||||
const url = `https://qun.qq.com/cgi-bin/group_digest/digest_list?random=665&X-CROSS-ORIGIN=fetch&group_code=${groupCode}&page_start=0&page_limit=20`
|
cn: number
|
||||||
const res = await this.request(url)
|
vn: number
|
||||||
log(res.headers)
|
settings: {
|
||||||
return await res.json()
|
is_show_edit_card: number
|
||||||
|
remind_ts: number
|
||||||
|
tip_window_type: number
|
||||||
|
confirm_required: number
|
||||||
}
|
}
|
||||||
|
read_num: number
|
||||||
private genBkn(sKey: string) {
|
is_read: number
|
||||||
return NTQQUserApi.genBkn(sKey)
|
is_all_confirm: number
|
||||||
|
}
|
||||||
|
export interface WebApiGroupNoticeRet {
|
||||||
|
ec: number
|
||||||
|
em: string
|
||||||
|
ltsm: number
|
||||||
|
srv_code: number
|
||||||
|
read_only: number
|
||||||
|
role: number
|
||||||
|
feeds: WebApiGroupNoticeFeed[]
|
||||||
|
group: {
|
||||||
|
group_id: number
|
||||||
|
class_ext: number
|
||||||
}
|
}
|
||||||
private async init() {
|
sta: number,
|
||||||
if (!WebApi.bkn) {
|
gln: number
|
||||||
const group = groups[0]
|
tst: number,
|
||||||
WebApi.skey = (await NTQQUserApi.getSkey(group.groupName, group.groupCode)).data
|
ui: any
|
||||||
WebApi.bkn = this.genBkn(WebApi.skey)
|
server_time: number
|
||||||
let cookie = await NTQQUserApi.getCookieWithoutSkey()
|
svrt: number
|
||||||
const pskeyRegex = /p_skey=([^;]+)/
|
ad: number
|
||||||
const match = cookie.match(pskeyRegex)
|
}
|
||||||
const pskeyValue = match ? match[1] : null
|
interface GroupEssenceMsg {
|
||||||
WebApi.pskey = pskeyValue
|
group_code: string
|
||||||
if (cookie.indexOf('skey=;') !== -1) {
|
msg_seq: number
|
||||||
cookie = cookie.replace('skey=;', `skey=${WebApi.skey};`)
|
msg_random: number
|
||||||
}
|
sender_uin: string
|
||||||
WebApi.cookie = cookie
|
sender_nick: string
|
||||||
// for(const kv of WebApi.cookie.split(";")){
|
sender_time: number
|
||||||
// const [key, value] = kv.split("=");
|
add_digest_uin: string
|
||||||
// }
|
add_digest_nick: string
|
||||||
// log("set cookie", key, value)
|
add_digest_time: number
|
||||||
// await session.defaultSession.cookies.set({
|
msg_content: any[]
|
||||||
// url: 'https://qun.qq.com', // 你要请求的域名
|
can_be_removed: true
|
||||||
// name: key.trim(),
|
}
|
||||||
// value: value.trim(),
|
export interface GroupEssenceMsgRet {
|
||||||
// expirationDate: Date.now() / 1000 + 300000, // Cookie 过期时间,例如设置为当前时间之后的300秒
|
retcode: number
|
||||||
// });
|
retmsg: string
|
||||||
// }
|
data: {
|
||||||
}
|
msg_list: GroupEssenceMsg[]
|
||||||
}
|
is_end: boolean
|
||||||
|
group_role: number
|
||||||
private async request(url: string, method: 'GET' | 'POST' = 'GET', headers: Record<string, string> = {}) {
|
config_page_url: string
|
||||||
await this.init()
|
}
|
||||||
url += '&bkn=' + WebApi.bkn
|
}
|
||||||
let _headers: Record<string, string> = {
|
export class WebApi {
|
||||||
...this.defaultHeaders,
|
static async getGroupEssenceMsg(GroupCode: string, page_start: string) {
|
||||||
...headers,
|
const _Pskey = (await NTQQUserApi.getPSkey(['qun.qq.com']))['qun.qq.com'];
|
||||||
Cookie: WebApi.cookie,
|
const _Skey = await NTQQUserApi.getSkey();
|
||||||
credentials: 'include',
|
const CookieValue = 'p_skey=' + _Pskey + '; skey=' + _Skey + '; p_uin=o' + selfInfo.uin + '; uin=o' + selfInfo.uin;
|
||||||
}
|
if (!_Skey || !_Pskey) {
|
||||||
log('request', url, _headers)
|
//获取Cookies失败
|
||||||
const options = {
|
return undefined;
|
||||||
method: method,
|
}
|
||||||
headers: _headers,
|
const Bkn = WebApi.genBkn(_Skey);
|
||||||
}
|
const url = 'https://qun.qq.com/cgi-bin/group_digest/digest_list?bkn=' + Bkn + '&group_code=' + GroupCode + '&page_start=' + page_start + '&page_limit=20';
|
||||||
return fetch(url, options)
|
let ret;
|
||||||
|
try {
|
||||||
|
ret = await RequestUtil.HttpGetJson<GroupEssenceMsgRet>(url, 'GET', '', { 'Cookie': CookieValue });
|
||||||
|
} catch {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
//console.log(url, CookieValue);
|
||||||
|
if (ret.retcode !== 0) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
static async getGroupMembers(GroupCode: string, cached: boolean = true): Promise<WebApiGroupMember[]> {
|
||||||
|
log('webapi 获取群成员', GroupCode);
|
||||||
|
let MemberData: Array<WebApiGroupMember> = new Array<WebApiGroupMember>();
|
||||||
|
try {
|
||||||
|
let cachedData = WebGroupData.GroupData.get(GroupCode);
|
||||||
|
let cachedTime = WebGroupData.GroupTime.get(GroupCode);
|
||||||
|
|
||||||
|
if (!cachedTime || Date.now() - cachedTime > 1800 * 1000 || !cached) {
|
||||||
|
const _Pskey = (await NTQQUserApi.getPSkey(['qun.qq.com']))['qun.qq.com'];
|
||||||
|
const _Skey = await NTQQUserApi.getSkey();
|
||||||
|
const CookieValue = 'p_skey=' + _Pskey + '; skey=' + _Skey + '; p_uin=o' + selfInfo.uin;
|
||||||
|
if (!_Skey || !_Pskey) {
|
||||||
|
return MemberData;
|
||||||
|
}
|
||||||
|
const Bkn = WebApi.genBkn(_Skey);
|
||||||
|
const retList: Promise<WebApiGroupMemberRet>[] = [];
|
||||||
|
const fastRet = await RequestUtil.HttpGetJson<WebApiGroupMemberRet>('https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?st=0&end=40&sort=1&gc=' + GroupCode + '&bkn=' + Bkn, 'POST', '', { 'Cookie': CookieValue });
|
||||||
|
if (!fastRet?.count || fastRet?.errcode !== 0 || !fastRet?.mems) {
|
||||||
|
return [];
|
||||||
|
} else {
|
||||||
|
for (const key in fastRet.mems) {
|
||||||
|
MemberData.push(fastRet.mems[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//初始化获取PageNum
|
||||||
|
const PageNum = Math.ceil(fastRet.count / 40);
|
||||||
|
//遍历批量请求
|
||||||
|
for (let i = 2; i <= PageNum; i++) {
|
||||||
|
const ret: Promise<WebApiGroupMemberRet> = RequestUtil.HttpGetJson<WebApiGroupMemberRet>('https://qun.qq.com/cgi-bin/qun_mgr/search_group_members?st=' + (i - 1) * 40 + '&end=' + i * 40 + '&sort=1&gc=' + GroupCode + '&bkn=' + Bkn, 'POST', '', { 'Cookie': CookieValue });
|
||||||
|
retList.push(ret);
|
||||||
|
}
|
||||||
|
//批量等待
|
||||||
|
for (let i = 1; i <= PageNum; i++) {
|
||||||
|
const ret = await (retList[i]);
|
||||||
|
if (!ret?.count || ret?.errcode !== 0 || !ret?.mems) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (const key in ret.mems) {
|
||||||
|
MemberData.push(ret.mems[key]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
WebGroupData.GroupData.set(GroupCode, MemberData);
|
||||||
|
WebGroupData.GroupTime.set(GroupCode, Date.now());
|
||||||
|
} else {
|
||||||
|
MemberData = cachedData as Array<WebApiGroupMember>;
|
||||||
|
}
|
||||||
|
} catch {
|
||||||
|
return MemberData;
|
||||||
|
}
|
||||||
|
return MemberData;
|
||||||
|
}
|
||||||
|
// public static async addGroupDigest(groupCode: string, msgSeq: string) {
|
||||||
|
// const url = `https://qun.qq.com/cgi-bin/group_digest/cancel_digest?random=665&X-CROSS-ORIGIN=fetch&group_code=${groupCode}&msg_seq=${msgSeq}&msg_random=444021292`;
|
||||||
|
// const res = await this.request(url);
|
||||||
|
// return await res.json();
|
||||||
|
// }
|
||||||
|
|
||||||
|
// public async getGroupDigest(groupCode: string) {
|
||||||
|
// const url = `https://qun.qq.com/cgi-bin/group_digest/digest_list?random=665&X-CROSS-ORIGIN=fetch&group_code=${groupCode}&page_start=0&page_limit=20`;
|
||||||
|
// const res = await this.request(url);
|
||||||
|
// return await res.json();
|
||||||
|
// }
|
||||||
|
static async setGroupNotice(GroupCode: string, Content: string = '') {
|
||||||
|
//https://web.qun.qq.com/cgi-bin/announce/add_qun_notice?bkn=${bkn}
|
||||||
|
//qid=${群号}&bkn=${bkn}&text=${内容}&pinned=0&type=1&settings={"is_show_edit_card":1,"tip_window_type":1,"confirm_required":1}
|
||||||
|
const _Pskey = (await NTQQUserApi.getPSkey(['qun.qq.com']))['qun.qq.com'];
|
||||||
|
const _Skey = await NTQQUserApi.getSkey();
|
||||||
|
const CookieValue = 'p_skey=' + _Pskey + '; skey=' + _Skey + '; p_uin=o' + selfInfo.uin;
|
||||||
|
let ret: any = undefined;
|
||||||
|
//console.log(CookieValue);
|
||||||
|
if (!_Skey || !_Pskey) {
|
||||||
|
//获取Cookies失败
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const Bkn = WebApi.genBkn(_Skey);
|
||||||
|
const data = 'qid=' + GroupCode + '&bkn=' + Bkn + '&text=' + Content + '&pinned=0&type=1&settings={"is_show_edit_card":1,"tip_window_type":1,"confirm_required":1}';
|
||||||
|
const url = 'https://web.qun.qq.com/cgi-bin/announce/add_qun_notice?bkn=' + Bkn;
|
||||||
|
try {
|
||||||
|
ret = await RequestUtil.HttpGetJson<any>(url, 'GET', '', { 'Cookie': CookieValue });
|
||||||
|
return ret;
|
||||||
|
} catch (e) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
static async getGrouptNotice(GroupCode: string): Promise<undefined | WebApiGroupNoticeRet> {
|
||||||
|
const _Pskey = (await NTQQUserApi.getPSkey(['qun.qq.com']))['qun.qq.com'];
|
||||||
|
const _Skey = await NTQQUserApi.getSkey();
|
||||||
|
const CookieValue = 'p_skey=' + _Pskey + '; skey=' + _Skey + '; p_uin=o' + selfInfo.uin;
|
||||||
|
let ret: WebApiGroupNoticeRet | undefined = undefined;
|
||||||
|
//console.log(CookieValue);
|
||||||
|
if (!_Skey || !_Pskey) {
|
||||||
|
//获取Cookies失败
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
const Bkn = WebApi.genBkn(_Skey);
|
||||||
|
const url = 'https://web.qun.qq.com/cgi-bin/announce/get_t_list?bkn=' + Bkn + '&qid=' + GroupCode + '&ft=23&ni=1&n=1&i=1&log_read=1&platform=1&s=-1&n=20';
|
||||||
|
try {
|
||||||
|
ret = await RequestUtil.HttpGetJson<WebApiGroupNoticeRet>(url, 'GET', '', { 'Cookie': CookieValue });
|
||||||
|
if (ret?.ec !== 0) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return ret;
|
||||||
|
} catch (e) {
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
static genBkn(sKey: string) {
|
||||||
|
sKey = sKey || '';
|
||||||
|
let hash = 5381;
|
||||||
|
|
||||||
|
for (let i = 0; i < sKey.length; i++) {
|
||||||
|
const code = sKey.charCodeAt(i);
|
||||||
|
hash = hash + (hash << 5) + code;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (hash & 0x7FFFFFFF).toString();
|
||||||
|
}
|
||||||
|
//实现未缓存 考虑2h缓存
|
||||||
|
static async getGroupHonorInfo(groupCode: string, getType: WebHonorType) {
|
||||||
|
const _Pskey = (await NTQQUserApi.getPSkey(['qun.qq.com']))['qun.qq.com'];
|
||||||
|
const _Skey = await NTQQUserApi.getSkey();
|
||||||
|
if (!_Skey || !_Pskey) {
|
||||||
|
//获取Cookies失败
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
async function getDataInternal(Internal_groupCode: string, Internal_type: number) {
|
||||||
|
let url = 'https://qun.qq.com/interactive/honorlist?gc=' + Internal_groupCode + '&type=' + Internal_type.toString();
|
||||||
|
let res = '';
|
||||||
|
let resJson;
|
||||||
|
try {
|
||||||
|
res = await RequestUtil.HttpGetText(url, 'GET', '', { 'Cookie': CookieValue });
|
||||||
|
const match = res.match(/window\.__INITIAL_STATE__=(.*?);/);
|
||||||
|
if (match) {
|
||||||
|
resJson = JSON.parse(match[1].trim());
|
||||||
|
}
|
||||||
|
if (Internal_type === 1) {
|
||||||
|
return resJson?.talkativeList;
|
||||||
|
} else {
|
||||||
|
return resJson?.actorList;
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log('获取当前群荣耀失败', url, e);
|
||||||
|
}
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
|
||||||
|
let HonorInfo: any = { group_id: groupCode };
|
||||||
|
const CookieValue = 'p_skey=' + _Pskey + '; skey=' + _Skey + '; p_uin=o' + selfInfo.uin + '; uin=o' + selfInfo.uin;
|
||||||
|
|
||||||
|
if (getType === WebHonorType.TALKACTIVE || getType === WebHonorType.ALL) {
|
||||||
|
try {
|
||||||
|
let RetInternal = await getDataInternal(groupCode, 1);
|
||||||
|
if (!RetInternal) {
|
||||||
|
throw new Error('获取龙王信息失败');
|
||||||
|
}
|
||||||
|
HonorInfo.current_talkative = {
|
||||||
|
user_id: RetInternal[0]?.uin,
|
||||||
|
avatar: RetInternal[0]?.avatar,
|
||||||
|
nickname: RetInternal[0]?.name,
|
||||||
|
day_count: 0,
|
||||||
|
description: RetInternal[0]?.desc
|
||||||
|
}
|
||||||
|
HonorInfo.talkative_list = [];
|
||||||
|
for (const talkative_ele of RetInternal) {
|
||||||
|
HonorInfo.talkative_list.push({
|
||||||
|
user_id: talkative_ele?.uin,
|
||||||
|
avatar: talkative_ele?.avatar,
|
||||||
|
description: talkative_ele?.desc,
|
||||||
|
day_count: 0,
|
||||||
|
nickname: talkative_ele?.name
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getType === WebHonorType.PERFROMER || getType === WebHonorType.ALL) {
|
||||||
|
try {
|
||||||
|
let RetInternal = await getDataInternal(groupCode, 2);
|
||||||
|
if (!RetInternal) {
|
||||||
|
throw new Error('获取群聊之火失败');
|
||||||
|
}
|
||||||
|
HonorInfo.performer_list = [];
|
||||||
|
for (const performer_ele of RetInternal) {
|
||||||
|
HonorInfo.performer_list.push({
|
||||||
|
user_id: performer_ele?.uin,
|
||||||
|
nickname: performer_ele?.name,
|
||||||
|
avatar: performer_ele?.avatar,
|
||||||
|
description: performer_ele?.desc
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getType === WebHonorType.PERFROMER || getType === WebHonorType.ALL) {
|
||||||
|
try {
|
||||||
|
let RetInternal = await getDataInternal(groupCode, 3);
|
||||||
|
if (!RetInternal) {
|
||||||
|
throw new Error('获取群聊炽焰失败');
|
||||||
|
}
|
||||||
|
HonorInfo.legend_list = [];
|
||||||
|
for (const legend_ele of RetInternal) {
|
||||||
|
HonorInfo.legend_list.push({
|
||||||
|
user_id: legend_ele?.uin,
|
||||||
|
nickname: legend_ele?.name,
|
||||||
|
avatar: legend_ele?.avatar,
|
||||||
|
desc: legend_ele?.description
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log('获取群聊炽焰失败', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (getType === WebHonorType.EMOTION || getType === WebHonorType.ALL) {
|
||||||
|
try {
|
||||||
|
let RetInternal = await getDataInternal(groupCode, 6);
|
||||||
|
if (!RetInternal) {
|
||||||
|
throw new Error('获取快乐源泉失败');
|
||||||
|
}
|
||||||
|
HonorInfo.emotion_list = [];
|
||||||
|
for (const emotion_ele of RetInternal) {
|
||||||
|
HonorInfo.emotion_list.push({
|
||||||
|
user_id: emotion_ele?.uin,
|
||||||
|
nickname: emotion_ele?.name,
|
||||||
|
avatar: emotion_ele?.avatar,
|
||||||
|
desc: emotion_ele?.description
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
log('获取快乐源泉失败', e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
//冒尖小春笋好像已经被tx扬了
|
||||||
|
if (getType === WebHonorType.EMOTION || getType === WebHonorType.ALL) {
|
||||||
|
HonorInfo.strong_newbie_list = [];
|
||||||
|
}
|
||||||
|
return HonorInfo;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@@ -4,7 +4,6 @@ import { hookApiCallbacks, ReceiveCmd, ReceiveCmdS, registerReceiveHook, removeR
|
|||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import { log } from '../common/utils/log'
|
import { log } from '../common/utils/log'
|
||||||
import { NTQQWindow, NTQQWindowApi, NTQQWindows } from './api/window'
|
import { NTQQWindow, NTQQWindowApi, NTQQWindows } from './api/window'
|
||||||
import { WebApi } from './api/webapi'
|
|
||||||
import { HOOK_LOG } from '../common/config'
|
import { HOOK_LOG } from '../common/config'
|
||||||
|
|
||||||
export enum NTQQApiClass {
|
export enum NTQQApiClass {
|
||||||
|
Reference in New Issue
Block a user