diff --git a/src/core/apis/sign.ts b/src/core/apis/sign.ts index 2b09b92a..f84f618e 100644 --- a/src/core/apis/sign.ts +++ b/src/core/apis/sign.ts @@ -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 { - type: 'custom', - url: string, - audio: string, - title: string, - image?: string, - singer?: string -} +import { RequestUtil } from '@/common/utils/request'; +import { MiniAppLuaJsonType } from '../entities/sign'; +import { InstanceContext, NapCatCore } from '..'; + // let t = await napCatCore.session.getGroupService().shareDigest({ // appId: "100497308", // appType: 1, @@ -89,220 +73,220 @@ export interface CustomMusicSignPostData { // }); // } // } -export interface MiniAppLuaJsonType { - prompt: string, - title: string, - preview: string, - jumpUrl: string, - tag: string, - tagIcon: string, - source: string, - sourcelogo: string, -} -export async function 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" - // } - // } - // } +export class NTQQMusicSignApi { + context: InstanceContext; + core: NapCatCore; + constructor(context: InstanceContext, core: NapCatCore) { + 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; - // }, - // + // 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, "\\/\\/") + // 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.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); } - }; - // 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; } - return signed_ark; -} -export async function 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"}' - 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.0, - 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; -} -//注意处理错误 -export async function CreateMusicThridWay0(id: string = '', mid: string = '') { - 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 - ); - mid = MusicInfo.songinfo?.data?.track_info.mid!; + 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"}' + 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.0, + 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 CreateMusicThridWay0(id: string = '', mid: string = '') { + 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 + ); + 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; -} diff --git a/src/core/apis/user.ts b/src/core/apis/user.ts index 95f9b455..016e446e 100644 --- a/src/core/apis/user.ts +++ b/src/core/apis/user.ts @@ -159,7 +159,7 @@ export class NTQQUserApi { //需要异常处理 async getCookies(domain: string) { 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); return cookies; } @@ -180,7 +180,7 @@ export class NTQQUserApi { async getQzoneCookies() { 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); return cookies; } @@ -193,7 +193,7 @@ export class NTQQUserApi { } const clientKey = ClientKeyData.clientKey; 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); const skey = cookies['skey']; if (!skey) { diff --git a/src/core/apis/webapi.ts b/src/core/apis/webapi.ts index b2026fd0..913bee2b 100644 --- a/src/core/apis/webapi.ts +++ b/src/core/apis/webapi.ts @@ -3,7 +3,7 @@ import { InstanceContext } from '../wrapper'; import { NapCatCore } from '..'; import { GroupEssenceMsgRet, WebApiGroupMember, WebApiGroupMemberRet, WebApiGroupNoticeRet, WebHonorType } from '../entities/webapi'; -export class WebApi { +export class NTQQWebApi { context: InstanceContext; core: NapCatCore; constructor(context: InstanceContext, core: NapCatCore) { diff --git a/src/core/core.ts b/src/core/core.ts index b21131a3..79040875 100644 --- a/src/core/core.ts +++ b/src/core/core.ts @@ -8,7 +8,7 @@ import { MsgListener, ProfileListener } from "./listeners"; import { sleep } from "@/common/utils/helper"; import { SelfInfo, LineDevice, SelfStatusInfo } from "./entities"; 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 { Unknown = 0, @@ -41,10 +41,11 @@ export class NapCatCore { this.eventWrapper = new LegacyNTEventWrapper(context.wrapper, context.session); this.initNapCatCoreListeners().then().catch(console.error); this.ApiContext = { - FriendApi: new NTQQFriendApi(this.context,this), - MsgApi: new NTQQMsgApi(this.context,this), - UserApi: new NTQQUserApi(this.context,this), - GroupApi: new NTQQGroupApi(this.context,this) + WebApi: new NTQQWebApi(this.context, this), + FriendApi: new NTQQFriendApi(this.context, this), + MsgApi: new NTQQMsgApi(this.context, this), + UserApi: new NTQQUserApi(this.context, this), + GroupApi: new NTQQGroupApi(this.context, this) }; } getApiContext() { diff --git a/src/core/entities/index.ts b/src/core/entities/index.ts index d2b2b6ad..9e947a8d 100644 --- a/src/core/entities/index.ts +++ b/src/core/entities/index.ts @@ -5,3 +5,4 @@ export * from './notify'; export * from './cache'; export * from './system'; export * from './webapi'; +export * from './sign'; \ No newline at end of file diff --git a/src/core/entities/sign.ts b/src/core/entities/sign.ts new file mode 100644 index 00000000..597d8691 --- /dev/null +++ b/src/core/entities/sign.ts @@ -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, + } \ No newline at end of file diff --git a/src/core/wrapper/context.ts b/src/core/wrapper/context.ts index 1337a034..70e97fea 100644 --- a/src/core/wrapper/context.ts +++ b/src/core/wrapper/context.ts @@ -4,7 +4,7 @@ import { NapCatCoreWorkingEnv } from "@/core"; import { SelfInfo } from "../entities"; import { NodeIKernelLoginService } from "../services"; import { WrapperNodeApi, NodeIQQNTWrapperSession } from "@/core"; -import { NTQQFriendApi, NTQQGroupApi, NTQQMsgApi, NTQQUserApi } from "../apis"; +import { NTQQFriendApi, NTQQGroupApi, NTQQMsgApi, NTQQUserApi, NTQQWebApi } from "../apis"; export interface InstanceContext { readonly workingEnv: NapCatCoreWorkingEnv; @@ -15,6 +15,7 @@ export interface InstanceContext { readonly basicInfoWrapper: QQBasicInfoWrapper; } export interface NTApiContext { + WebApi: NTQQWebApi, FriendApi: NTQQFriendApi, MsgApi: NTQQMsgApi, UserApi: NTQQUserApi,