Skip to content

Commit

Permalink
1.5.0
Browse files Browse the repository at this point in the history
  • Loading branch information
idranme committed Jul 29, 2024
1 parent 8656ab2 commit 107dd9f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 6 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "koishi-plugin-music-downloadvoice-api",
"description": "Provide the selected song as a voice",
"version": "1.4.3",
"version": "1.5.0",
"main": "lib/index.js",
"typings": "lib/index.d.ts",
"files": [
Expand Down
18 changes: 13 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Context, Schema, h, isNullable } from 'koishi'
import { } from 'koishi-plugin-puppeteer'
import { Context, Schema, h, isNullable, Time } from 'koishi'
import type { } from 'koishi-plugin-puppeteer'

export const name = 'music-downloadvoice-api'
export const inject = {
Expand All @@ -19,12 +19,14 @@ export interface Config {
recall: boolean
imageMode: boolean
darkMode: boolean
maxDuration: number
}

export const Config: Schema<Config> = Schema.intersect([
Schema.object({
generationTip: Schema.string().description('生成语音时返回的文字提示内容').default('生成语音中…'),
waitTimeout: Schema.natural().role('ms').min(1000).step(1000).description('等待用户选择歌曲序号的最长时间').default(45000)
waitTimeout: Schema.natural().role('ms').min(Time.second).step(Time.second).description('等待用户选择歌曲序号的最长时间')
.default(45 * Time.second)
}).description('基础设置'),
Schema.object({
imageMode: Schema.boolean().description('开启后返回图片歌单,关闭后返回文本歌单').required(),
Expand All @@ -33,8 +35,10 @@ export const Config: Schema<Config> = Schema.intersect([
Schema.object({
exitCommand: Schema.string().description('退出选择指令,多个指令间请用逗号分隔开').default('0, 不听了'),
menuExitCommandTip: Schema.boolean().description('是否在歌单内容的后面,加上退出选择指令的文字提示').default(false),
recall: Schema.boolean().description('是否在发送语音后撤回 generationTip').default(true)
}).description('进阶设置'),
recall: Schema.boolean().description('是否在发送语音后撤回 generationTip').default(true),
maxDuration: Schema.natural().role('ms').min(Time.minute).step(Time.minute).description('歌曲最长持续时间,单位为毫秒')
.default(70 * Time.minute)
}).description('进阶设置')
])

interface SongData {
Expand Down Expand Up @@ -306,6 +310,10 @@ export function apply(ctx: Context, cfg: Config) {
}
try {
const duration = timeStringToSeconds(interval)
if (duration * 1000 > cfg.maxDuration) {
if (cfg.recall) session.bot.deleteMessage(channelId, tipMessageId)
return `${h.quote(quoteId)}歌曲持续时间超出限制。`
}
const url = new URL(src)
if (url.host.startsWith('ws.stream')) {
url.host = url.host.replace('ws.stream', 'isure6.stream')
Expand Down

0 comments on commit 107dd9f

Please sign in to comment.