mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-21 09:36:35 +00:00
fix: signApi
This commit is contained in:
parent
6583e3d0c9
commit
abe0838a63
@ -1,24 +1,8 @@
|
|||||||
import { logDebug } from '@/common/utils/log';
|
|
||||||
import { NTQQUserApi } from './user';
|
|
||||||
import { selfInfo } from '../data';
|
|
||||||
import { RequestUtil } from '@/common/utils/request';
|
|
||||||
import { WebApi } from './webapi';
|
|
||||||
import { checkFileReceived, checkFileReceived2, uri2local } from '@/common/utils/file';
|
|
||||||
import fs from 'node:fs';
|
|
||||||
import { sleep } from '@/common/utils/helper';
|
|
||||||
export interface IdMusicSignPostData {
|
|
||||||
type: 'qq' | '163',
|
|
||||||
id: string | number,
|
|
||||||
}
|
|
||||||
|
|
||||||
export interface CustomMusicSignPostData {
|
import { RequestUtil } from '@/common/utils/request';
|
||||||
type: 'custom',
|
import { MiniAppLuaJsonType } from '../entities/sign';
|
||||||
url: string,
|
import { InstanceContext, NapCatCore } from '..';
|
||||||
audio: string,
|
|
||||||
title: string,
|
|
||||||
image?: string,
|
|
||||||
singer?: string
|
|
||||||
}
|
|
||||||
// let t = await napCatCore.session.getGroupService().shareDigest({
|
// let t = await napCatCore.session.getGroupService().shareDigest({
|
||||||
// appId: "100497308",
|
// appId: "100497308",
|
||||||
// appType: 1,
|
// appType: 1,
|
||||||
@ -89,220 +73,220 @@ export interface CustomMusicSignPostData {
|
|||||||
// });
|
// });
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
export interface MiniAppLuaJsonType {
|
export class NTQQMusicSignApi {
|
||||||
prompt: string,
|
context: InstanceContext;
|
||||||
title: string,
|
core: NapCatCore;
|
||||||
preview: string,
|
constructor(context: InstanceContext, core: NapCatCore) {
|
||||||
jumpUrl: string,
|
this.context = context;
|
||||||
tag: string,
|
this.core = core;
|
||||||
tagIcon: string,
|
}
|
||||||
source: string,
|
async SignMiniApp(CardData: MiniAppLuaJsonType) {
|
||||||
sourcelogo: string,
|
// {
|
||||||
}
|
// "app": "com.tencent.miniapp.lua",
|
||||||
export async function SignMiniApp(CardData: MiniAppLuaJsonType) {
|
// "bizsrc": "tianxuan.imgJumpArk",
|
||||||
// {
|
// "view": "miniapp",
|
||||||
// "app": "com.tencent.miniapp.lua",
|
// "prompt": "hi! 这里有我的日常故事,只想讲给你听",
|
||||||
// "bizsrc": "tianxuan.imgJumpArk",
|
// "config": {
|
||||||
// "view": "miniapp",
|
// "type": "normal",
|
||||||
// "prompt": "hi! 这里有我的日常故事,只想讲给你听",
|
// "forward": 1,
|
||||||
// "config": {
|
// "autosize": 0
|
||||||
// "type": "normal",
|
// },
|
||||||
// "forward": 1,
|
// "meta": {
|
||||||
// "autosize": 0
|
// "miniapp": {
|
||||||
// },
|
// "title": "hi! 这里有我的日常故事,只想讲给你听",
|
||||||
// "meta": {
|
// "preview": "https:\/\/tianquan.gtimg.cn\/qqAIAgent\/item\/7\/square.png",
|
||||||
// "miniapp": {
|
// "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",
|
||||||
// "title": "hi! 这里有我的日常故事,只想讲给你听",
|
// "tag": "QQ智能体",
|
||||||
// "preview": "https:\/\/tianquan.gtimg.cn\/qqAIAgent\/item\/7\/square.png",
|
// "tagIcon": "https:\/\/tianquan.gtimg.cn\/shoal\/qqAIAgent\/3e9d70c9-d98c-45b8-80b4-79d82971b514.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",
|
// "source": "QQ智能体",
|
||||||
// "tag": "QQ智能体",
|
// "sourcelogo": "https:\/\/tianquan.gtimg.cn\/shoal\/qqAIAgent\/3e9d70c9-d98c-45b8-80b4-79d82971b514.png"
|
||||||
// "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){
|
// token : function(url,skey){
|
||||||
// var str = skey || cookie('skey') || cookie('rv2') || '',
|
// var str = skey || cookie('skey') || cookie('rv2') || '',
|
||||||
// hash = 5381;
|
// hash = 5381;
|
||||||
// if(url){
|
// if(url){
|
||||||
// var hostname = uri(url).hostname;
|
// 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)){
|
// 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;
|
// str = cookie('p_skey') || str;
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
// for(var i = 0, len = str.length; i < len; ++i){
|
// for(var i = 0, len = str.length; i < len; ++i){
|
||||||
// hash += (hash << 5) + str.charAt(i).charCodeAt();
|
// hash += (hash << 5) + str.charAt(i).charCodeAt();
|
||||||
// }
|
// }
|
||||||
// return hash & 0x7fffffff;
|
// return hash & 0x7fffffff;
|
||||||
// },
|
// },
|
||||||
//
|
//
|
||||||
|
|
||||||
// function signToken(skey: string) {
|
// function signToken(skey: string) {
|
||||||
// let hash = 5381;
|
// let hash = 5381;
|
||||||
// for (let i = 0, len = skey.length; i < len; ++i) {
|
// for (let i = 0, len = skey.length; i < len; ++i) {
|
||||||
// hash += (hash << 5) + skey.charCodeAt(i);
|
// hash += (hash << 5) + skey.charCodeAt(i);
|
||||||
// }
|
// }
|
||||||
// return hash & 0x7fffffff;
|
// return hash & 0x7fffffff;
|
||||||
// }
|
// }
|
||||||
const signCard = {
|
const signCard = {
|
||||||
"app": "com.tencent.miniapp.lua",
|
"app": "com.tencent.miniapp.lua",
|
||||||
"bizsrc": "tianxuan.imgJumpArk",
|
"bizsrc": "tianxuan.imgJumpArk",
|
||||||
"view": "miniapp",
|
"view": "miniapp",
|
||||||
"prompt": CardData.prompt,
|
"prompt": CardData.prompt,
|
||||||
"config": {
|
"config": {
|
||||||
"type": "normal",
|
"type": "normal",
|
||||||
"forward": 1,
|
"forward": 1,
|
||||||
"autosize": 0
|
"autosize": 0
|
||||||
},
|
},
|
||||||
"meta": {
|
"meta": {
|
||||||
"miniapp": {
|
"miniapp": {
|
||||||
"title": CardData.title,
|
"title": CardData.title,
|
||||||
"preview": (CardData.preview as string).replace(/\\/g, "\\/\\/"),
|
"preview": (CardData.preview as string).replace(/\\/g, "\\/\\/"),
|
||||||
"jumpUrl": (CardData.jumpUrl as string).replace(/\\/g, "\\/\\/"),
|
"jumpUrl": (CardData.jumpUrl as string).replace(/\\/g, "\\/\\/"),
|
||||||
"tag": CardData.tag,
|
"tag": CardData.tag,
|
||||||
"tagIcon": (CardData.tagIcon as string).replace(/\\/g, "\\/\\/"),
|
"tagIcon": (CardData.tagIcon as string).replace(/\\/g, "\\/\\/"),
|
||||||
"source": CardData.source,
|
"source": CardData.source,
|
||||||
"sourcelogo": (CardData.sourcelogo as string).replace(/\\/g, "\\/\\/")
|
"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.getApiContext().UserApi.getQzoneCookies());
|
||||||
|
const Bkn = this.core.getApiContext().WebApi.genBkn(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;
|
||||||
// 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 NTQQUserApi.getQzoneCookies());
|
|
||||||
const Bkn = WebApi.genBkn(data.p_skey);
|
|
||||||
|
|
||||||
const CookieValue = 'p_skey=' + data.p_skey + '; skey=' + data.skey + '; p_uin=o' + selfInfo.uin + '; uin=o' + 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) {
|
|
||||||
logDebug('MiniApp JSON 消息生成失败', error);
|
|
||||||
}
|
}
|
||||||
return signed_ark;
|
async SignMusicInternal(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"}'
|
||||||
export async function SignMusicInternal(songname: string, singer: string, cover: string, songmid: string, songmusic: string) {
|
const signurl = 'https://mqq.reader.qq.com/api/mqq/share/card?accessToken&_csrfToken&source=c0003';
|
||||||
//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"}'
|
//let = "https://y.qq.com/music/photo_new/T002R800x800M000000MkMni19ClKG.jpg";
|
||||||
const signurl = 'https://mqq.reader.qq.com/api/mqq/share/card?accessToken&_csrfToken&source=c0003';
|
const signCard = {
|
||||||
//let = "https://y.qq.com/music/photo_new/T002R800x800M000000MkMni19ClKG.jpg";
|
app: "com.tencent.qqreader.share",
|
||||||
const signCard = {
|
config: {
|
||||||
app: "com.tencent.qqreader.share",
|
ctime: 1718634110,
|
||||||
config: {
|
forward: 1,
|
||||||
ctime: 1718634110,
|
token: "9a63343c32d5a16bcde653eb97faa25d",
|
||||||
forward: 1,
|
type: "normal"
|
||||||
token: "9a63343c32d5a16bcde653eb97faa25d",
|
},
|
||||||
type: "normal"
|
extra: {
|
||||||
},
|
app_type: 1,
|
||||||
extra: {
|
appid: 100497308,
|
||||||
app_type: 1,
|
msg_seq: 14386738075403815000.0,
|
||||||
appid: 100497308,
|
uin: 1733139081
|
||||||
msg_seq: 14386738075403815000.0,
|
},
|
||||||
uin: 1733139081
|
meta: {
|
||||||
},
|
music:
|
||||||
meta: {
|
{
|
||||||
music:
|
action: "",
|
||||||
{
|
android_pkg_name: "",
|
||||||
action: "",
|
app_type: 1,
|
||||||
android_pkg_name: "",
|
appid: 100497308,
|
||||||
app_type: 1,
|
ctime: 1718634110,
|
||||||
appid: 100497308,
|
desc: singer,
|
||||||
ctime: 1718634110,
|
jumpUrl: "https://i.y.qq.com/v8/playsong.html?songmid=" + songmid + "&type=0",
|
||||||
desc: singer,
|
musicUrl: songmusic,
|
||||||
jumpUrl: "https://i.y.qq.com/v8/playsong.html?songmid=" + songmid + "&type=0",
|
preview: cover,
|
||||||
musicUrl: songmusic,
|
cover: cover,
|
||||||
preview: cover,
|
sourceMsgId: "0",
|
||||||
cover: cover,
|
source_icon: "https://p.qpic.cn/qqconnect/0/app_100497308_1626060999/100?max-age=2592000&t=0",
|
||||||
sourceMsgId: "0",
|
source_url: "",
|
||||||
source_icon: "https://p.qpic.cn/qqconnect/0/app_100497308_1626060999/100?max-age=2592000&t=0",
|
tag: "QQ音乐",
|
||||||
source_url: "",
|
title: songname,
|
||||||
tag: "QQ音乐",
|
uin: 10086
|
||||||
title: songname,
|
}
|
||||||
uin: 10086
|
},
|
||||||
}
|
prompt: "[分享]" + songname,
|
||||||
},
|
ver: "0.0.0.1",
|
||||||
prompt: "[分享]" + songname,
|
view: "music"
|
||||||
ver: "0.0.0.1",
|
};
|
||||||
view: "music"
|
//console.log(JSON.stringify(signCard, null, 2));
|
||||||
};
|
const data = await RequestUtil.HttpGetJson<{ code: number, data: { arkResult: string } }>
|
||||||
//console.log(JSON.stringify(signCard, null, 2));
|
(signurl, 'POST', signCard, { 'Cookie': 'uin=o10086', 'Content-Type': 'application/json' });
|
||||||
const data = await RequestUtil.HttpGetJson<{ code: number, data: { arkResult: string } }>
|
return data;
|
||||||
(signurl, 'POST', signCard, { 'Cookie': 'uin=o10086', 'Content-Type': 'application/json' });
|
}
|
||||||
return data;
|
//注意处理错误
|
||||||
}
|
async CreateMusicThridWay0(id: string = '', mid: string = '') {
|
||||||
//注意处理错误
|
if (mid == '') {
|
||||||
export async function CreateMusicThridWay0(id: string = '', mid: string = '') {
|
const MusicInfo = await RequestUtil.HttpGetJson
|
||||||
if (mid == '') {
|
<{ songinfo?: { data?: { track_info: { mid: string } } } }>
|
||||||
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',
|
||||||
'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"}}',
|
undefined
|
||||||
'GET',
|
);
|
||||||
undefined
|
mid = MusicInfo.songinfo?.data?.track_info.mid!;
|
||||||
);
|
}
|
||||||
mid = 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=' + mid + '&type=8', 'GET', undefined);
|
||||||
|
//console.log(MusicReal);
|
||||||
|
return { ...MusicReal.data, mid: mid };
|
||||||
|
}
|
||||||
|
async CreateMusicThridWay1(id: string = '', mid: string = '') {
|
||||||
|
|
||||||
|
}
|
||||||
|
//转换外域名为 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
|
||||||
|
|
||||||
|
//外域名不行得走qgroup中转
|
||||||
|
//https://proxy.gtimg.cn/tx_tls_gate=y.qq.com/music/photo_new/T002R800x800M000000y5gq7449K9I.jpg
|
||||||
|
|
||||||
|
//可外域名
|
||||||
|
//https://pic.ugcimg.cn/500955bdd6657ecc8e82e02d2df06800/jpg1
|
||||||
|
|
||||||
|
//QQ音乐gtimg接口
|
||||||
|
//https://y.gtimg.cn/music/photo_new/T002R800x800M000000y5gq7449K9I.jpg?max_age=2592000
|
||||||
|
|
||||||
|
//还有一处公告上传可以上传高质量图片 持久为qq域名
|
||||||
|
async SignMusicWrapper(id: string = '') {
|
||||||
|
const MusicInfo = await this.CreateMusicThridWay0(id)!;
|
||||||
|
const MusicCard = await this.SignMusicInternal(MusicInfo.name!, MusicInfo.singer!, MusicInfo.cover!, MusicInfo.mid!, "https://ws.stream.qqmusic.qq.com/" + MusicInfo.url!);
|
||||||
|
return MusicCard;
|
||||||
}
|
}
|
||||||
//第三方接口 存在速率限制 现在勉强用
|
|
||||||
const MusicReal = await RequestUtil.HttpGetJson
|
|
||||||
<{ code: number, data?: { name: string, singer: string, url: string, cover: string } }>
|
|
||||||
('https://api.leafone.cn/api/qqmusic?id=' + mid + '&type=8', 'GET', undefined);
|
|
||||||
//console.log(MusicReal);
|
|
||||||
return { ...MusicReal.data, mid: mid };
|
|
||||||
}
|
|
||||||
export async function CreateMusicThridWay1(id: string = '', mid: string = '') {
|
|
||||||
|
|
||||||
}
|
}
|
||||||
//转换外域名为 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
|
|
||||||
|
|
||||||
//外域名不行得走qgroup中转
|
|
||||||
//https://proxy.gtimg.cn/tx_tls_gate=y.qq.com/music/photo_new/T002R800x800M000000y5gq7449K9I.jpg
|
|
||||||
|
|
||||||
//可外域名
|
|
||||||
//https://pic.ugcimg.cn/500955bdd6657ecc8e82e02d2df06800/jpg1
|
|
||||||
|
|
||||||
//QQ音乐gtimg接口
|
|
||||||
//https://y.gtimg.cn/music/photo_new/T002R800x800M000000y5gq7449K9I.jpg?max_age=2592000
|
|
||||||
|
|
||||||
//还有一处公告上传可以上传高质量图片 持久为qq域名
|
|
||||||
export async function SignMusicWrapper(id: string = '') {
|
|
||||||
const MusicInfo = await CreateMusicThridWay0(id)!;
|
|
||||||
const MusicCard = await SignMusicInternal(MusicInfo.name!, MusicInfo.singer!, MusicInfo.cover!, MusicInfo.mid!, "https://ws.stream.qqmusic.qq.com/" + MusicInfo.url!);
|
|
||||||
return MusicCard;
|
|
||||||
}
|
|
||||||
|
@ -159,7 +159,7 @@ export class NTQQUserApi {
|
|||||||
//需要异常处理
|
//需要异常处理
|
||||||
async getCookies(domain: string) {
|
async getCookies(domain: string) {
|
||||||
const ClientKeyData = await this.forceFetchClientKey();
|
const ClientKeyData = await this.forceFetchClientKey();
|
||||||
const requestUrl = 'https://ssl.ptlogin2.qq.com/jump?ptlang=1033&clientuin=' + selfInfo.uin + '&clientkey=' + ClientKeyData.clientKey + '&u1=https%3A%2F%2F' + domain + '%2F' + selfInfo.uin + '%2Finfocenter&keyindex=19%27'
|
const requestUrl = 'https://ssl.ptlogin2.qq.com/jump?ptlang=1033&clientuin=' + this.core.selfInfo.uin + '&clientkey=' + ClientKeyData.clientKey + '&u1=https%3A%2F%2F' + domain + '%2F' + this.core.selfInfo.uin + '%2Finfocenter&keyindex=19%27'
|
||||||
let cookies: { [key: string]: string; } = await RequestUtil.HttpsGetCookies(requestUrl);
|
let cookies: { [key: string]: string; } = await RequestUtil.HttpsGetCookies(requestUrl);
|
||||||
return cookies;
|
return cookies;
|
||||||
}
|
}
|
||||||
@ -180,7 +180,7 @@ export class NTQQUserApi {
|
|||||||
|
|
||||||
async getQzoneCookies() {
|
async getQzoneCookies() {
|
||||||
const ClientKeyData = await this.forceFetchClientKey();
|
const ClientKeyData = await this.forceFetchClientKey();
|
||||||
const requestUrl = 'https://ssl.ptlogin2.qq.com/jump?ptlang=1033&clientuin=' + selfInfo.uin + '&clientkey=' + ClientKeyData.clientKey + '&u1=https%3A%2F%2Fuser.qzone.qq.com%2F' + selfInfo.uin + '%2Finfocenter&keyindex=19%27'
|
const requestUrl = 'https://ssl.ptlogin2.qq.com/jump?ptlang=1033&clientuin=' + this.core.selfInfo.uin + '&clientkey=' + ClientKeyData.clientKey + '&u1=https%3A%2F%2Fuser.qzone.qq.com%2F' + this.core.selfInfo.uin + '%2Finfocenter&keyindex=19%27'
|
||||||
let cookies: { [key: string]: string; } = await RequestUtil.HttpsGetCookies(requestUrl);
|
let cookies: { [key: string]: string; } = await RequestUtil.HttpsGetCookies(requestUrl);
|
||||||
return cookies;
|
return cookies;
|
||||||
}
|
}
|
||||||
@ -193,7 +193,7 @@ export class NTQQUserApi {
|
|||||||
}
|
}
|
||||||
const clientKey = ClientKeyData.clientKey;
|
const clientKey = ClientKeyData.clientKey;
|
||||||
const keyIndex = ClientKeyData.keyIndex;
|
const keyIndex = ClientKeyData.keyIndex;
|
||||||
const requestUrl = 'https://ssl.ptlogin2.qq.com/jump?ptlang=1033&clientuin=' + selfInfo.uin + '&clientkey=' + clientKey + '&u1=https%3A%2F%2Fh5.qzone.qq.com%2Fqqnt%2Fqzoneinpcqq%2Ffriend%3Frefresh%3D0%26clientuin%3D0%26darkMode%3D0&keyindex=19%27';
|
const requestUrl = 'https://ssl.ptlogin2.qq.com/jump?ptlang=1033&clientuin=' + this.core.selfInfo.uin + '&clientkey=' + clientKey + '&u1=https%3A%2F%2Fh5.qzone.qq.com%2Fqqnt%2Fqzoneinpcqq%2Ffriend%3Frefresh%3D0%26clientuin%3D0%26darkMode%3D0&keyindex=19%27';
|
||||||
let cookies: { [key: string]: string; } = await RequestUtil.HttpsGetCookies(requestUrl);
|
let cookies: { [key: string]: string; } = await RequestUtil.HttpsGetCookies(requestUrl);
|
||||||
const skey = cookies['skey'];
|
const skey = cookies['skey'];
|
||||||
if (!skey) {
|
if (!skey) {
|
||||||
|
@ -3,7 +3,7 @@ import { InstanceContext } from '../wrapper';
|
|||||||
import { NapCatCore } from '..';
|
import { NapCatCore } from '..';
|
||||||
import { GroupEssenceMsgRet, WebApiGroupMember, WebApiGroupMemberRet, WebApiGroupNoticeRet, WebHonorType } from '../entities/webapi';
|
import { GroupEssenceMsgRet, WebApiGroupMember, WebApiGroupMemberRet, WebApiGroupNoticeRet, WebHonorType } from '../entities/webapi';
|
||||||
|
|
||||||
export class WebApi {
|
export class NTQQWebApi {
|
||||||
context: InstanceContext;
|
context: InstanceContext;
|
||||||
core: NapCatCore;
|
core: NapCatCore;
|
||||||
constructor(context: InstanceContext, core: NapCatCore) {
|
constructor(context: InstanceContext, core: NapCatCore) {
|
||||||
|
@ -8,7 +8,7 @@ import { MsgListener, ProfileListener } from "./listeners";
|
|||||||
import { sleep } from "@/common/utils/helper";
|
import { sleep } from "@/common/utils/helper";
|
||||||
import { SelfInfo, LineDevice, SelfStatusInfo } from "./entities";
|
import { SelfInfo, LineDevice, SelfStatusInfo } from "./entities";
|
||||||
import { LegacyNTEventWrapper } from "@/common/framework/event-legacy";
|
import { LegacyNTEventWrapper } from "@/common/framework/event-legacy";
|
||||||
import { NTQQFriendApi, NTQQGroupApi, NTQQMsgApi, NTQQUserApi } from "./apis";
|
import { NTQQFriendApi, NTQQGroupApi, NTQQMsgApi, NTQQUserApi, NTQQWebApi } from "./apis";
|
||||||
|
|
||||||
export enum NapCatCoreWorkingEnv {
|
export enum NapCatCoreWorkingEnv {
|
||||||
Unknown = 0,
|
Unknown = 0,
|
||||||
@ -41,10 +41,11 @@ export class NapCatCore {
|
|||||||
this.eventWrapper = new LegacyNTEventWrapper(context.wrapper, context.session);
|
this.eventWrapper = new LegacyNTEventWrapper(context.wrapper, context.session);
|
||||||
this.initNapCatCoreListeners().then().catch(console.error);
|
this.initNapCatCoreListeners().then().catch(console.error);
|
||||||
this.ApiContext = {
|
this.ApiContext = {
|
||||||
FriendApi: new NTQQFriendApi(this.context,this),
|
WebApi: new NTQQWebApi(this.context, this),
|
||||||
MsgApi: new NTQQMsgApi(this.context,this),
|
FriendApi: new NTQQFriendApi(this.context, this),
|
||||||
UserApi: new NTQQUserApi(this.context,this),
|
MsgApi: new NTQQMsgApi(this.context, this),
|
||||||
GroupApi: new NTQQGroupApi(this.context,this)
|
UserApi: new NTQQUserApi(this.context, this),
|
||||||
|
GroupApi: new NTQQGroupApi(this.context, this)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
getApiContext() {
|
getApiContext() {
|
||||||
|
@ -5,3 +5,4 @@ export * from './notify';
|
|||||||
export * from './cache';
|
export * from './cache';
|
||||||
export * from './system';
|
export * from './system';
|
||||||
export * from './webapi';
|
export * from './webapi';
|
||||||
|
export * from './sign';
|
23
src/core/entities/sign.ts
Normal file
23
src/core/entities/sign.ts
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
export interface IdMusicSignPostData {
|
||||||
|
type: 'qq' | '163',
|
||||||
|
id: string | number,
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface CustomMusicSignPostData {
|
||||||
|
type: 'custom',
|
||||||
|
url: string,
|
||||||
|
audio: string,
|
||||||
|
title: string,
|
||||||
|
image?: string,
|
||||||
|
singer?: string
|
||||||
|
}
|
||||||
|
export interface MiniAppLuaJsonType {
|
||||||
|
prompt: string,
|
||||||
|
title: string,
|
||||||
|
preview: string,
|
||||||
|
jumpUrl: string,
|
||||||
|
tag: string,
|
||||||
|
tagIcon: string,
|
||||||
|
source: string,
|
||||||
|
sourcelogo: string,
|
||||||
|
}
|
@ -4,7 +4,7 @@ import { NapCatCoreWorkingEnv } from "@/core";
|
|||||||
import { SelfInfo } from "../entities";
|
import { SelfInfo } from "../entities";
|
||||||
import { NodeIKernelLoginService } from "../services";
|
import { NodeIKernelLoginService } from "../services";
|
||||||
import { WrapperNodeApi, NodeIQQNTWrapperSession } from "@/core";
|
import { WrapperNodeApi, NodeIQQNTWrapperSession } from "@/core";
|
||||||
import { NTQQFriendApi, NTQQGroupApi, NTQQMsgApi, NTQQUserApi } from "../apis";
|
import { NTQQFriendApi, NTQQGroupApi, NTQQMsgApi, NTQQUserApi, NTQQWebApi } from "../apis";
|
||||||
|
|
||||||
export interface InstanceContext {
|
export interface InstanceContext {
|
||||||
readonly workingEnv: NapCatCoreWorkingEnv;
|
readonly workingEnv: NapCatCoreWorkingEnv;
|
||||||
@ -15,6 +15,7 @@ export interface InstanceContext {
|
|||||||
readonly basicInfoWrapper: QQBasicInfoWrapper;
|
readonly basicInfoWrapper: QQBasicInfoWrapper;
|
||||||
}
|
}
|
||||||
export interface NTApiContext {
|
export interface NTApiContext {
|
||||||
|
WebApi: NTQQWebApi,
|
||||||
FriendApi: NTQQFriendApi,
|
FriendApi: NTQQFriendApi,
|
||||||
MsgApi: NTQQMsgApi,
|
MsgApi: NTQQMsgApi,
|
||||||
UserApi: NTQQUserApi,
|
UserApi: NTQQUserApi,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user