mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 04:45:46 +00:00
fix: error
This commit is contained in:
parent
21b228552d
commit
4cf52e1b13
@ -93,7 +93,7 @@ export class RequestUtil {
|
||||
});
|
||||
});
|
||||
|
||||
req.on('error', (error: any) => {
|
||||
req.on('error', (error: Error) => {
|
||||
reject(error);
|
||||
});
|
||||
if (method === 'POST' || method === 'PUT' || method === 'PATCH') {
|
||||
|
@ -41,14 +41,10 @@ export class NTQQFriendApi {
|
||||
tempBothDel: tempBothDel
|
||||
});
|
||||
}
|
||||
async getBuddyV2ExWithCate(refresh = false) {
|
||||
const categoryMap: Map<string, any> = new Map();
|
||||
async getBuddyV2ExWithCate() {
|
||||
const buddyService = this.context.session.getBuddyService();
|
||||
const buddyListV2 = (await buddyService.getBuddyListV2('0', BuddyListReqType.KNOMAL)).data;
|
||||
const uids = buddyListV2.flatMap(item => {
|
||||
item.buddyUids.forEach(uid => {
|
||||
categoryMap.set(uid, { categoryId: item.categoryId, categoryName: item.categroyName });
|
||||
});
|
||||
return item.buddyUids;
|
||||
});
|
||||
const data = await this.core.eventWrapper.callNoListenerEvent(
|
||||
|
@ -4,5 +4,4 @@ export * from './group';
|
||||
export * from './msg';
|
||||
export * from './user';
|
||||
export * from './webapi';
|
||||
export * from './sign';
|
||||
export * from './system';
|
@ -1,5 +1,3 @@
|
||||
import { RequestUtil } from '@/common/request';
|
||||
import { MiniAppLuaJsonType } from '@/core';
|
||||
import { InstanceContext, NapCatCore } from '..';
|
||||
|
||||
export class NTQQMusicSignApi {
|
||||
@ -10,210 +8,6 @@ export class NTQQMusicSignApi {
|
||||
this.context = context;
|
||||
this.core = core;
|
||||
}
|
||||
|
||||
async signMiniApp(CardData: MiniAppLuaJsonType) {
|
||||
// {
|
||||
// "app": "com.tencent.miniapp.lua",
|
||||
// "bizsrc": "tianxuan.imgJumpArk",
|
||||
// "view": "miniapp",
|
||||
// "prompt": "hi! 这里有我的日常故事,只想讲给你听",
|
||||
// "config": {
|
||||
// "type": "normal",
|
||||
// "forward": 1,
|
||||
// "autosize": 0
|
||||
// },
|
||||
// "meta": {
|
||||
// "miniapp": {
|
||||
// "title": "hi! 这里有我的日常故事,只想讲给你听",
|
||||
// "preview": "https:\/\/tianquan.gtimg.cn\/qqAIAgent\/item\/7\/square.png",
|
||||
// "jumpUrl": "https:\/\/club.vip.qq.com\/transfer?open_kuikly_info=%7B%22version%22%3A%20%221%22%2C%22src_type%22%3A%20%22web%22%2C%22kr_turbo_display%22%3A%20%221%22%2C%22page_name%22%3A%20%22vas_ai_persona_moments%22%2C%22bundle_name%22%3A%20%22vas_ai_persona_moments%22%7D&page_name=vas_ai_persona_moments&enteranceId=share&robot_uin=3889008584",
|
||||
// "tag": "QQ智能体",
|
||||
// "tagIcon": "https:\/\/tianquan.gtimg.cn\/shoal\/qqAIAgent\/3e9d70c9-d98c-45b8-80b4-79d82971b514.png",
|
||||
// "source": "QQ智能体",
|
||||
// "sourcelogo": "https:\/\/tianquan.gtimg.cn\/shoal\/qqAIAgent\/3e9d70c9-d98c-45b8-80b4-79d82971b514.png"
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
// token : function(url,skey){
|
||||
// var str = skey || cookie('skey') || cookie('rv2') || '',
|
||||
// hash = 5381;
|
||||
// if(url){
|
||||
// var hostname = uri(url).hostname;
|
||||
// if(hostname.indexOf('qun.qq.com') > -1 || (hostname.indexOf('qzone.qq.com') > -1 && hostname.indexOf('qun.qzone.qq.com') === -1)){
|
||||
// str = cookie('p_skey') || str;
|
||||
// }
|
||||
// }
|
||||
// for(var i = 0, len = str.length; i < len; ++i){
|
||||
// hash += (hash << 5) + str.charAt(i).charCodeAt();
|
||||
// }
|
||||
// return hash & 0x7fffffff;
|
||||
// },
|
||||
//
|
||||
|
||||
// function signToken(skey: string) {
|
||||
// let hash = 5381;
|
||||
// for (let i = 0, len = skey.length; i < len; ++i) {
|
||||
// hash += (hash << 5) + skey.charCodeAt(i);
|
||||
// }
|
||||
// return hash & 0x7fffffff;
|
||||
// }
|
||||
const signCard = {
|
||||
'app': 'com.tencent.miniapp.lua',
|
||||
'bizsrc': 'tianxuan.imgJumpArk',
|
||||
'view': 'miniapp',
|
||||
'prompt': CardData.prompt,
|
||||
'config': {
|
||||
'type': 'normal',
|
||||
'forward': 1,
|
||||
'autosize': 0,
|
||||
},
|
||||
'meta': {
|
||||
'miniapp': {
|
||||
'title': CardData.title,
|
||||
'preview': (CardData.preview as string).replace(/\\/g, '\\/\\/'),
|
||||
'jumpUrl': (CardData.jumpUrl as string).replace(/\\/g, '\\/\\/'),
|
||||
'tag': CardData.tag,
|
||||
'tagIcon': (CardData.tagIcon as string).replace(/\\/g, '\\/\\/'),
|
||||
'source': CardData.source,
|
||||
'sourcelogo': (CardData.sourcelogo as string).replace(/\\/g, '\\/\\/'),
|
||||
},
|
||||
},
|
||||
};
|
||||
// let signCard = {
|
||||
// "app": "com.tencent.eventshare.lua",
|
||||
// "prompt": "Bot Test",
|
||||
// "bizsrc": "tianxuan.business",
|
||||
// "meta": {
|
||||
// "eventshare": {
|
||||
// "button1URL": "https://www.bilibili.com",
|
||||
// "button1disable": false,
|
||||
// "button1title": "点我前往",
|
||||
// "button2URL": "",
|
||||
// "button2disable": false,
|
||||
// "button2title": "",
|
||||
// "buttonNum": 1,
|
||||
// "jumpURL": "https://www.bilibili.com",
|
||||
// "preview": "https://tianquan.gtimg.cn/shoal/card/9930bc4e-4a92-4da3-814f-8094a2421d9c.png",
|
||||
// "tag": "QQ集卡",
|
||||
// "tagIcon": "https://tianquan.gtimg.cn/shoal/card/c034854b-102d-40be-a545-5ca90a7c49c9.png",
|
||||
// "title": "Bot Test"
|
||||
// }
|
||||
// },
|
||||
// "config": {
|
||||
// "autosize": 0,
|
||||
// "collect": 0,
|
||||
// "ctime": 1716568575,
|
||||
// "forward": 1,
|
||||
// "height": 336,
|
||||
// "reply": 0,
|
||||
// "round": 1,
|
||||
// "type": "normal",
|
||||
// "width": 263
|
||||
// },
|
||||
// "view": "eventshare",
|
||||
// "ver": "0.0.0.1"
|
||||
// };
|
||||
const data = (await this.core.apis.UserApi.getQzoneCookies());
|
||||
const Bkn = this.core.apis.WebApi.getBknFromCookie(data.p_skey);
|
||||
|
||||
const CookieValue = 'p_skey=' + data.p_skey + '; skey=' + data.skey + '; p_uin=o' + this.core.selfInfo.uin + '; uin=o' + this.core.selfInfo.uin;
|
||||
|
||||
const signurl = 'https://h5.qzone.qq.com/v2/vip/tx/trpc/ark-share/GenNewSignedArk?g_tk=' + Bkn + '&ark=' + encodeURIComponent(JSON.stringify(signCard));
|
||||
let signed_ark = '';
|
||||
try {
|
||||
const retData = await RequestUtil.HttpGetJson<{
|
||||
code: number,
|
||||
data: { signed_ark: string }
|
||||
}>(signurl, 'GET', undefined, { Cookie: CookieValue });
|
||||
//logDebug('MiniApp JSON 消息生成成功', retData);
|
||||
signed_ark = retData.data.signed_ark;
|
||||
} catch (error) {
|
||||
this.context.logger.logDebug('MiniApp JSON 消息生成失败', error);
|
||||
}
|
||||
return signed_ark;
|
||||
}
|
||||
|
||||
async signInternal(songname: string, singer: string, cover: string, songmid: string, songmusic: string) {
|
||||
//curl -X POST 'https://mqq.reader.qq.com/api/mqq/share/card?accessToken&_csrfToken&source=c0003' -H 'Content-Type: application/json' -H 'Cookie: uin=o10086' -d '{"app":"com.tencent.qqreader.share","config":{"ctime":1718634110,"forward":1,"token":"9a63343c32d5a16bcde653eb97faa25d","type":"normal"},"extra":{"app_type":1,"appid":100497308,"msg_seq":14386738075403815000.0,"uin":1733139081},"meta":{"music":{"action":"","android_pkg_name":"","app_type":1,"appid":100497308,"ctime":1718634110,"desc":"周杰伦","jumpUrl":"https://i.y.qq.com/v8/playsong.html?songmid=0039MnYb0qxYhV&type=0","musicUrl":"http://ws.stream.qqmusic.qq.com/http://isure6.stream.qqmusic.qq.com/M800002202B43Cq4V4.mp3?fromtag=810033622&guid=br_xzg&trace=23fe7bcbe2336bbf&uin=553&vkey=CF0F5CE8B0FA16F3001F8A88D877A217EB5E4F00BDCEF1021EB6C48969CA33C6303987AEECE9CC840122DD2F917A59D6130D8A8CA4577C87","preview":"https://y.qq.com/music/photo_new/T002R800x800M000000MkMni19ClKG.jpg","cover":"https://y.qq.com/music/photo_new/T002R800x800M000000MkMni19ClKG.jpg","sourceMsgId":"0","source_icon":"https://p.qpic.cn/qqconnect/0/app_100497308_1626060999/100?max-age=2592000&t=0","source_url":"","tag":"QQ音乐","title":"晴天","uin":10086}},"prompt":"[分享]晴天","ver":"0.0.0.1","view":"music"}'
|
||||
const signurl = 'https://mqq.reader.qq.com/api/mqq/share/card?accessToken&_csrfToken&source=c0003';
|
||||
//let = "https://y.qq.com/music/photo_new/T002R800x800M000000MkMni19ClKG.jpg";
|
||||
const signCard = {
|
||||
app: 'com.tencent.qqreader.share',
|
||||
config: {
|
||||
ctime: 1718634110,
|
||||
forward: 1,
|
||||
token: '9a63343c32d5a16bcde653eb97faa25d',
|
||||
type: 'normal',
|
||||
},
|
||||
extra: {
|
||||
app_type: 1,
|
||||
appid: 100497308,
|
||||
msg_seq: 14386738075403815000,
|
||||
uin: 1733139081,
|
||||
},
|
||||
meta: {
|
||||
music: {
|
||||
action: '',
|
||||
android_pkg_name: '',
|
||||
app_type: 1,
|
||||
appid: 100497308,
|
||||
ctime: 1718634110,
|
||||
desc: singer,
|
||||
jumpUrl: 'https://i.y.qq.com/v8/playsong.html?songmid=' + songmid + '&type=0',
|
||||
musicUrl: songmusic,
|
||||
preview: cover,
|
||||
cover: cover,
|
||||
sourceMsgId: '0',
|
||||
source_icon: 'https://p.qpic.cn/qqconnect/0/app_100497308_1626060999/100?max-age=2592000&t=0',
|
||||
source_url: '',
|
||||
tag: 'QQ音乐',
|
||||
title: songname,
|
||||
uin: 10086,
|
||||
},
|
||||
},
|
||||
prompt: '[分享]' + songname,
|
||||
ver: '0.0.0.1',
|
||||
view: 'music',
|
||||
};
|
||||
//console.log(JSON.stringify(signCard, null, 2));
|
||||
const data = await RequestUtil.HttpGetJson<{ code: number, data: { arkResult: string } }>
|
||||
(signurl, 'POST', signCard, { 'Cookie': 'uin=o10086', 'Content-Type': 'application/json' });
|
||||
return data;
|
||||
}
|
||||
|
||||
//注意处理错误
|
||||
async signWay03(id: string = '', mid: string = '') {
|
||||
let signedMid;
|
||||
if (mid == '') {
|
||||
const MusicInfo = await RequestUtil.HttpGetJson<{
|
||||
songinfo?: {
|
||||
data?: {
|
||||
track_info: {
|
||||
mid: string
|
||||
}
|
||||
}
|
||||
}
|
||||
}>(
|
||||
'https://u.y.qq.com/cgi-bin/musicu.fcg?format=json&inCharset=utf8&outCharset=utf-8¬ice=0&platform=yqq.json&needNewCode=0&data={"comm":{"ct":24,"cv":0},"songinfo":{"method":"get_song_detail_yqq","param":{"song_type":0,"song_mid":"","song_id":' + id + '},"module":"music.pf_song_detail_svr"}}',
|
||||
'GET',
|
||||
undefined,
|
||||
);
|
||||
signedMid = MusicInfo.songinfo?.data?.track_info.mid;
|
||||
}
|
||||
//第三方接口 存在速率限制 现在勉强用
|
||||
const MusicReal = await RequestUtil.HttpGetJson<{
|
||||
code: number,
|
||||
data?: {
|
||||
name: string,
|
||||
singer: string,
|
||||
url: string,
|
||||
cover: string
|
||||
}
|
||||
}>('https://api.leafone.cn/api/qqmusic?id=' + signedMid + '&type=8', 'GET');
|
||||
//console.log(MusicReal);
|
||||
return { ...MusicReal.data, mid: signedMid };
|
||||
}
|
||||
//转换外域名为 https://qq.ugcimg.cn/v1/cpqcbu4b8870i61bde6k7cbmjgejq8mr3in82qir4qi7ielffv5slv8ck8g42novtmev26i233ujtuab6tvu2l2sjgtupfr389191v00s1j5oh5325j5eqi40774jv1i/khovifoh7jrqd6eahoiv7koh8o
|
||||
//https://cgi.connect.qq.com/qqconnectopen/openapi/change_image_url?url=https://th.bing.com/th?id=OSK.b8ed36f1fb1889de6dc84fd81c187773&w=46&h=46&c=11&rs=1&qlt=80&o=6&dpr=2&pid=SANGAM
|
||||
|
||||
@ -227,10 +21,5 @@ export class NTQQMusicSignApi {
|
||||
//https://y.gtimg.cn/music/photo_new/T002R800x800M000000y5gq7449K9I.jpg?max_age=2592000
|
||||
|
||||
//还有一处公告上传可以上传高质量图片 持久为qq域名
|
||||
async SignMusicWrapper(id: string = '') {
|
||||
const MusicInfo = await this.signWay03(id)!;
|
||||
return await this.signInternal(MusicInfo.name!, MusicInfo.singer!, MusicInfo.cover!, MusicInfo.mid!, 'https://ws.stream.qqmusic.qq.com/' + MusicInfo.url!);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ export interface ChatCacheList {
|
||||
export interface ChatCacheListItem {
|
||||
chatType: ChatType;
|
||||
basicChatCacheInfo: ChatCacheListItemBasic;
|
||||
guildChatCacheInfo: unknown[]; // TODO: 没用过频道所以不知道这里边的详细内容
|
||||
guildChatCacheInfo: unknown[]; // work: 没用过频道所以不知道这里边的详细内容
|
||||
}
|
||||
|
||||
export interface ChatCacheListItemBasic {
|
||||
|
@ -175,8 +175,8 @@ export interface SimpleInfo {
|
||||
status: UserStatus | null;
|
||||
vasInfo: VasInfo | null;
|
||||
relationFlags: RelationFlags | null;
|
||||
otherFlags: any | null;
|
||||
intimate: any | null;
|
||||
otherFlags: any;
|
||||
intimate: any;
|
||||
}
|
||||
|
||||
export type FriendV2 = SimpleInfo;
|
||||
|
@ -220,7 +220,7 @@ export class NapCatCore {
|
||||
if (existMember) {
|
||||
Object.assign(existMember, member);
|
||||
} else {
|
||||
existMembers!.set(uid, member);
|
||||
existMembers.set(uid, member);
|
||||
}
|
||||
//移除成员
|
||||
if (member.isDelete) {
|
||||
|
@ -20,8 +20,8 @@ export interface OnRichMediaDownloadCompleteParams {
|
||||
fileSrvErrCode: string,
|
||||
clientMsg: string,
|
||||
businessId: number,
|
||||
userTotalSpacePerDay: unknown | null,
|
||||
userUsedSpacePerDay: unknown | null
|
||||
userTotalSpacePerDay: unknown,
|
||||
userUsedSpacePerDay: unknown
|
||||
}
|
||||
|
||||
export interface GroupFileInfoUpdateParamType {
|
||||
|
@ -1,40 +0,0 @@
|
||||
import { constants } from "node:os";
|
||||
import path from "path";
|
||||
import { dlopen } from "process";
|
||||
import fs from "fs";
|
||||
export class Native {
|
||||
platform: string;
|
||||
supportedPlatforms = [''];
|
||||
MoeHooExport: any = { exports: {} };
|
||||
recallHookEnabled: boolean = false;
|
||||
inited = true;
|
||||
constructor(nodePath: string, platform: string = process.platform) {
|
||||
this.platform = platform;
|
||||
try {
|
||||
if (!this.supportedPlatforms.includes(this.platform)) {
|
||||
throw new Error(`Platform ${this.platform} is not supported`);
|
||||
}
|
||||
const nativeNode = path.join(nodePath, './native/MoeHoo.win32.node');
|
||||
if (fs.existsSync(nativeNode)) {
|
||||
dlopen(this.MoeHooExport, nativeNode, constants.dlopen.RTLD_LAZY);
|
||||
}
|
||||
} catch (error) {
|
||||
this.inited = false;
|
||||
}
|
||||
|
||||
}
|
||||
isSetReCallEnabled(): boolean {
|
||||
return this.recallHookEnabled && this.inited;
|
||||
}
|
||||
registerRecallCallback(callback: (hex: string) => any): void {
|
||||
try {
|
||||
if (!this.inited) throw new Error('Native Not Init');
|
||||
if (this.MoeHooExport.exports?.registMsgPush) {
|
||||
this.MoeHooExport.exports.registMsgPush(callback);
|
||||
this.recallHookEnabled = true;
|
||||
}
|
||||
} catch (error) {
|
||||
this.recallHookEnabled = false;
|
||||
}
|
||||
}
|
||||
}
|
@ -6,7 +6,7 @@ export class GetFriendWithCategory extends BaseAction<void, any> {
|
||||
actionName = ActionName.GetFriendsWithCategory;
|
||||
|
||||
async _handle(payload: void) {
|
||||
return (await this.core.apis.FriendApi.getBuddyV2ExWithCate(true)).map(category => ({
|
||||
return (await this.core.apis.FriendApi.getBuddyV2ExWithCate()).map(category => ({
|
||||
...category,
|
||||
buddyList: OB11Entities.friendsV2(category.buddyList),
|
||||
}));
|
||||
|
Loading…
Reference in New Issue
Block a user