Compare commits

..

No commits in common. "a7e701cbb25866cc47355a75567428e229626bc0" and "941c5a2cc6f313ad89a95ede397c432500b3e766" have entirely different histories.

3 changed files with 18 additions and 83 deletions

View File

@ -79,21 +79,6 @@
- `早安`
- `晚安`
</details>
<details>
<summary>点歌功能</summary>
- 使用[hifi公共音源库](https://github.com/sachinsenal0x64/hifi)提供服务,
- 由于音源位于海外,大陆连接下载音乐时可能遇到缓慢问题,考虑优化网络环境
- 由于海外音源,搜歌时考虑使用繁体中文,英文等进行搜索以处理搜索不到的情况
- 默认下载flac/CD无损级音乐,可在配置文件调整为mp3音质或直接通过语音发送
- ~~可以听周杰伦~~
- `#点歌晴天`
- `#听1`
- `#听夜曲`
> 直接#听+歌曲名可能播放错误的歌曲
</details>
<details>
<summary>晶灵智能✨</summary>
@ -157,8 +142,7 @@
"welcome": true,
"faceReply": true,
"ai": true,
"blackWords": true,
"music": true
"blackWords": true
}
```
</details>
@ -231,23 +215,6 @@
}
```
</details>
<details>
<summary>music.json</summary>
```
{
"?url": "api地址,不建议修改",
"url": "https://api.401658.xyz",
"?username&&password": "请勿修改",
"username": "crystelf",
"password": "1145141919810",
"?quality": "1为96kbpsAAC,2为320kbpsAAC,3为最高16-bit/44.1kHzflac",
"quality": "3"
}
```
</details>
<details>
<summary>ai.json</summary>
@ -271,10 +238,6 @@
"maxSessions": 10,
"?chatHistory": "聊天上下文最大长度",
"chatHistory": 10,
"?maxMessageLength": "最大消息长度,如果消息长度大于这个值,超出的部分将会被截断",
"maxMessageLength": 100,
"?getChatHistoryLength": "获取到的聊天上下文长度,ai可以看到多少条群聊的聊天记录",
"getChatHistoryLength":20,
"?blockGroup": "禁用的群聊(黑名单)",
"blockGroup": [],
"?whiteGroup": "白名单群聊,存在该部分时,黑名单将被禁用",

View File

@ -25,11 +25,11 @@ export class CrystelfMusic extends plugin {
priority: -1000,
rule: [
{
reg: '^#?点歌\\s*(.+)$',
reg: '^#?点歌\\s+(.+)$',
fnc: 'handleSearch'
},
{
reg: '^#?听\\s*(.+)',
reg: '^#?听\\s+(.+)$',
fnc: 'handleDirectPlay'
},
{
@ -46,9 +46,6 @@ export class CrystelfMusic extends plugin {
*/
async handleSearch(e) {
try {
if (!ConfigControl.get()?.config?.music) {
return;
}
const keyword = e.msg.replace(/^#?点歌\s*/, '').trim();
if (!keyword) {
return await e.reply('请输入要点的歌名,例如:#点歌 夜曲');
@ -56,6 +53,7 @@ export class CrystelfMusic extends plugin {
const adapter = await YunzaiUtils.getAdapter(e);
await Message.emojiLike(e,e.message_id,60,e.group_id,adapter);
const result = await musicSearch.handleSearch(e, keyword);
if (result.success) {
await e.reply({
type: 'image',
@ -64,6 +62,7 @@ export class CrystelfMusic extends plugin {
} else {
await e.reply(`${result.message}`, true);
}
} catch (error) {
logger.error('[crystelf-music] 处理搜索失败:', error);
await e.reply('搜索失败,请稍后重试', true);
@ -76,38 +75,18 @@ export class CrystelfMusic extends plugin {
*/
async handleDirectPlay(e) {
try {
if (!ConfigControl.get()?.config?.music) {
return;
}
const content = e.msg.replace(/^#?听\s*/, '').trim();
if (!content) {
return await e.reply('请输入要听的歌名或序号,例如:#听 夜曲 或 #听 1', true);
}
const index = parseInt(content);
if (!isNaN(index) && index >= 1 && index <= 20) {
const searchResult = musicSearch.getGroupSearchResult(e.group_id);
if (!searchResult) {
return await e.reply('没有找到当前可选择的音乐列表,请先搜索歌曲', true);
const songName = e.msg.replace(/^#?听\s*/, '').trim();
if (!songName) {
return await e.reply('请输入要听的歌名,例如:#听 夜曲', true);
}
const adapter = await YunzaiUtils.getAdapter(e);
await Message.emojiLike(e,e.message_id,60,e.group_id,adapter);
const result = await musicSearch.handleSelection(e, index);
const result = await musicSearch.handleDirectPlay(e, songName);
if (result.success) {
await this.sendMusicResult(e, result);
} else {
await e.reply(`${result.message}`, true);
}
} else {
const adapter = await YunzaiUtils.getAdapter(e);
await Message.emojiLike(e, e.message_id, 60, e.group_id, adapter);
const result = await musicSearch.handleDirectPlay(e, content);
if (result.success) {
await this.sendMusicResult(e, result);
} else {
await e.reply(`${result.message}`, true);
}
}
} catch (error) {
logger.error('[crystelf-music] 处理直接播放失败:', error);
await e.reply('播放失败,请稍后重试', true);
@ -120,9 +99,6 @@ export class CrystelfMusic extends plugin {
*/
async handleIndexSelection(e) {
try {
if (!ConfigControl.get()?.config?.music) {
return;
}
const index = parseInt(e.msg);
if (isNaN(index) || index < 1 || index > 20) {
return;
@ -136,7 +112,6 @@ export class CrystelfMusic extends plugin {
const result = await musicSearch.handleSelection(e, index);
if (result.success) {
await this.sendMusicResult(e, result);
await musicSearch.clearGroupSearch(e.group_id);
} else {
await e.reply(`${result.message}`, true);
}
@ -159,9 +134,7 @@ export class CrystelfMusic extends plugin {
await Group.sendGroupRecord(e, e.group_id, `file://${audioFile}`, adapter);
} else {
const extension = await this.getFileExtension();
const sanitizedTitle = song.displayTitle.replace(/\s+/g, '_');
const sanitizedArtist = song.displayArtist.replace(/\s+/g, '_');
const filename = `${sanitizedTitle} - ${sanitizedArtist}.${extension}`;
const filename = `${song.displayTitle} - ${song.displayArtist}.${extension}`;
await Group.sendGroupFile(e, e.group_id, `file://${audioFile}`, filename, adapter);
}
musicSearch.clearUserSelection(e.group_id, e.user_id);

View File

@ -15,6 +15,5 @@
"welcome": true,
"faceReply": true,
"ai": true,
"blackWords": true,
"music": true
"blackWords": true
}