mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
fix: music params check
This commit is contained in:
parent
ec27d73605
commit
24a49f035e
@ -34,7 +34,7 @@ import { sleep } from '../../../common/utils/helper'
|
|||||||
import { uri2local } from '../../../common/utils'
|
import { uri2local } from '../../../common/utils'
|
||||||
import { crychic } from '../../../ntqqapi/external/crychic'
|
import { crychic } from '../../../ntqqapi/external/crychic'
|
||||||
import { NTQQGroupApi } from '../../../ntqqapi/api'
|
import { NTQQGroupApi } from '../../../ntqqapi/api'
|
||||||
import { CustomMusicSignPostData, MusicSign, MusicSignPostData } from '../../../common/utils/sign'
|
import { CustomMusicSignPostData, IdMusicSignPostData, MusicSign, MusicSignPostData } from '../../../common/utils/sign'
|
||||||
|
|
||||||
function checkSendMessage(sendMsgList: OB11MessageData[]) {
|
function checkSendMessage(sendMsgList: OB11MessageData[]) {
|
||||||
function checkUri(uri: string): boolean {
|
function checkUri(uri: string): boolean {
|
||||||
@ -402,9 +402,28 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
|||||||
}
|
}
|
||||||
const postData: MusicSignPostData = { ...music.data }
|
const postData: MusicSignPostData = { ...music.data }
|
||||||
if (type === 'custom' && music.data.content) {
|
if (type === 'custom' && music.data.content) {
|
||||||
|
|
||||||
;(postData as CustomMusicSignPostData).singer = music.data.content
|
;(postData as CustomMusicSignPostData).singer = music.data.content
|
||||||
delete (postData as OB11MessageCustomMusic['data']).content
|
delete (postData as OB11MessageCustomMusic['data']).content
|
||||||
}
|
}
|
||||||
|
if (type === 'custom'){
|
||||||
|
const customMusicData = music.data as CustomMusicSignPostData
|
||||||
|
if (!customMusicData.url){
|
||||||
|
throw ('自定义音卡缺少参数url');
|
||||||
|
}
|
||||||
|
if (!customMusicData.audio){
|
||||||
|
throw('自定义音卡缺少参数audio');
|
||||||
|
}
|
||||||
|
if (!customMusicData.title){
|
||||||
|
throw('自定义音卡缺少参数title');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (type === 'qq' || type === '163') {
|
||||||
|
const idMusicData = music.data as IdMusicSignPostData;
|
||||||
|
if (!idMusicData.id) {
|
||||||
|
throw '音乐卡片缺少id参数'
|
||||||
|
}
|
||||||
|
}
|
||||||
let jsonContent: string
|
let jsonContent: string
|
||||||
try {
|
try {
|
||||||
jsonContent = await new MusicSign(musicSignUrl).sign(postData)
|
jsonContent = await new MusicSign(musicSignUrl).sign(postData)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user