mirror of
https://github.com/NapNeko/NapCatQQ.git
synced 2024-11-16 04:45:46 +00:00
Merge pull request #392 from Fripine/feat/more-music-types
feat: support more types of music cards
This commit is contained in:
commit
f49b94edb9
@ -1,14 +1,15 @@
|
|||||||
export interface IdMusicSignPostData {
|
export interface IdMusicSignPostData {
|
||||||
type: 'qq' | '163',
|
type: 'qq' | '163' | 'kugou' | 'migu' | 'kuwo',
|
||||||
id: string | number,
|
id: string | number,
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface CustomMusicSignPostData {
|
export interface CustomMusicSignPostData {
|
||||||
type: 'custom',
|
type: 'qq' | '163' | 'kugou' | 'migu' | 'kuwo' | 'custom',
|
||||||
|
id: undefined,
|
||||||
url: string,
|
url: string,
|
||||||
audio: string,
|
audio?: string,
|
||||||
title: string,
|
title?: string,
|
||||||
image?: string,
|
image: string,
|
||||||
singer?: string
|
singer?: string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,32 +547,28 @@ export class OneBotMsgApi {
|
|||||||
|
|
||||||
[OB11MessageDataType.music]: async ({ data }, context) => {
|
[OB11MessageDataType.music]: async ({ data }, context) => {
|
||||||
// 保留, 直到...找到更好的解决方案
|
// 保留, 直到...找到更好的解决方案
|
||||||
if (data.type === 'custom') {
|
if (data.id !== undefined) {
|
||||||
|
if (!['qq', '163', 'kugou', 'kuwo', 'migu'].includes(data.type)) {
|
||||||
|
this.core.context.logger.logError('音乐卡片type错误, 只支持qq、163、kugou、kuwo、migu,当前type:', data.type);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!['qq', '163', 'kugou', 'kuwo', 'migu', 'custom'].includes(data.type)) {
|
||||||
|
this.core.context.logger.logError('音乐卡片type错误, 只支持qq、163、kugou、kuwo、migu、custom,当前type:', data.type);
|
||||||
|
return undefined;
|
||||||
|
}
|
||||||
if (!data.url) {
|
if (!data.url) {
|
||||||
this.core.context.logger.logError('自定义音卡缺少参数url');
|
this.core.context.logger.logError('自定义音卡缺少参数url');
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
if (!data.audio) {
|
if (!data.image) {
|
||||||
this.core.context.logger.logError('自定义音卡缺少参数audio');
|
this.core.context.logger.logError('自定义音卡缺少参数image');
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
if (!data.title) {
|
|
||||||
this.core.context.logger.logError('自定义音卡缺少参数title');
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
if (!['qq', '163'].includes(data.type)) {
|
|
||||||
this.core.context.logger.logError('音乐卡片type错误, 只支持qq、163、custom,当前type:', data.type);
|
|
||||||
return undefined;
|
|
||||||
}
|
|
||||||
if (!data.id) {
|
|
||||||
this.core.context.logger.logError('音乐卡片缺少参数id');
|
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let postData: IdMusicSignPostData | CustomMusicSignPostData;
|
let postData: IdMusicSignPostData | CustomMusicSignPostData;
|
||||||
if (data.type === 'custom' && data.content) {
|
if (data.id === undefined && data.content) {
|
||||||
const { content, ...others } = data;
|
const { content, ...others } = data;
|
||||||
postData = { singer: content, ...others };
|
postData = { singer: content, ...others };
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
Reference in New Issue
Block a user