mirror of
https://github.com/LLOneBot/LLOneBot.git
synced 2024-11-22 01:56:33 +00:00
fix
This commit is contained in:
parent
6ff49722d8
commit
1d7100a053
@ -14,6 +14,8 @@ export interface CustomMusicSignPostData {
|
||||
singer?: string
|
||||
}
|
||||
|
||||
export type MusicSignPostData = IdMusicSignPostData | CustomMusicSignPostData
|
||||
|
||||
export class MusicSign {
|
||||
private readonly url: string
|
||||
|
||||
@ -21,7 +23,7 @@ export class MusicSign {
|
||||
this.url = url
|
||||
}
|
||||
|
||||
async sign(postData: CustomMusicSignPostData | IdMusicSignPostData): Promise<any> {
|
||||
async sign(postData: MusicSignPostData): Promise<any> {
|
||||
const resp = await fetch(this.url, {
|
||||
method: 'POST',
|
||||
headers: { 'Content-Type': 'application/json' },
|
||||
|
@ -33,7 +33,7 @@ import { sleep } from '../../../common/utils/helper'
|
||||
import { uri2local } from '../../../common/utils'
|
||||
import { crychic } from '../../../ntqqapi/external/crychic'
|
||||
import { NTQQGroupApi } from '../../../ntqqapi/api'
|
||||
import { MusicSign } from '../../../common/utils/sign'
|
||||
import { CustomMusicSignPostData, MusicSign, MusicSignPostData } from '../../../common/utils/sign'
|
||||
|
||||
function checkSendMessage(sendMsgList: OB11MessageData[]) {
|
||||
function checkUri(uri: string): boolean {
|
||||
@ -304,6 +304,13 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
message: '转发消息不能和普通消息混在一起发送,转发需要保证message只有type为node的元素',
|
||||
}
|
||||
}
|
||||
const musicNum = this.getSpecialMsgNum(payload, OB11MessageDataType.music)
|
||||
if (musicNum > 1 || fmNum != messages.length) {
|
||||
return {
|
||||
valid: false,
|
||||
message: '音乐消息不可以和其他消息混在一起发送',
|
||||
}
|
||||
}
|
||||
if (payload.message_type !== 'private' && payload.group_id && !(await getGroup(payload.group_id))) {
|
||||
return {
|
||||
valid: false,
|
||||
@ -388,9 +395,14 @@ export class SendMsg extends BaseAction<OB11PostSendMsg, ReturnDataType> {
|
||||
if (!['qq', '163', 'custom'].includes(type)) {
|
||||
throw `不支持的音乐类型 ${type}`
|
||||
}
|
||||
const postData: MusicSignPostData = { ...music.data }
|
||||
if (type === 'custom' && music.data.content) {
|
||||
;(postData as CustomMusicSignPostData).singer = music.data.content
|
||||
delete (postData as OB11MessageCustomMusic['data']).content
|
||||
}
|
||||
let jsonContent: string
|
||||
try {
|
||||
jsonContent = await new MusicSign(musicSignUrl).sign(music.data)
|
||||
jsonContent = await new MusicSign(musicSignUrl).sign(postData)
|
||||
} catch (e) {
|
||||
throw `签名音乐消息失败:${e}`
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user