@dgck81lnn/koishi-plugin-music 0.1.4 → 0.1.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/index.js CHANGED
@@ -92,14 +92,14 @@ function apply(ctx, config) {
92
92
  .command("musicjs <code:rawtext>", { strictOptions: true })
93
93
  .action(async ({ session }, code) => {
94
94
  if (!code)
95
- return session.text(".require-code");
95
+ return session.i18n(".require-code");
96
96
  try {
97
97
  new Function(code);
98
98
  }
99
99
  catch (e) {
100
100
  return koishi_1.h.text(String(e));
101
101
  }
102
- let gutteredCode = `(${gutterFunc})(${new Function("$", "with($){" + code + "}")})`;
102
+ let gutteredCode = `(${gutterFunc})(function($){with($){\n${code}\n}})`;
103
103
  if (config.evalCommand !== "eval")
104
104
  gutteredCode = `process.stdout.write(${gutteredCode})`;
105
105
  ctx.logger.debug(config.evalCommand, gutteredCode);
@@ -112,7 +112,7 @@ function apply(ctx, config) {
112
112
  });
113
113
  const data = (0, koishi_1.h)("", await session.execute(evalArgv, true)).toString(true);
114
114
  if (!data)
115
- session.text(".no-note");
115
+ return session.i18n(".no-note");
116
116
  try {
117
117
  ctx.logger.debug(JSON.parse(data));
118
118
  }
@@ -1 +1 @@
1
- {"commands":{"musicjs":{"description":"用 JavaScript 代码演奏旋律","usage":"函数及其参数说明:\n note(tone: number, beats: number, temperament = 12) 创建平均律音符\n tone 音符相对于基准音的偏移(默认情况下,单位为半音)\n beats 音符时长(拍)\n temperament 平均律的音阶数;决定了多少 tone 为一个八度\n noteJust(ratio: number, beats: number) 创建纯律音符\n ratio 音符音高与基准音频率的比值\n beats 音符时长(拍)\n noteHz(frequency: number, beats: number) 创建指定频率音高的音符\n frequency 频率(赫兹)\n beats 音符时长(拍)\n rest(beats: number) 休止\n beats 休止时长(拍)\n变量说明——修改这些变量会影响后续创建音符的属性:\n bpm: Number = 120 每分钟拍数\n 由于兼容原因,除非给该变量赋过值,否则读取该变量得到的是一个可以被隐式转换成数字的函数。\n baseFrequency = 440 基准音频率\n gain = 0.5 音量\n time = 0 当前时间(秒)\n 调用 note、rest 等函数后此变量的值会自动增加。\n 修改此值后再添加音符可以使不同音符同时播放。","messages":{"require-code":"缺少代码。","no-note":"未定义任何音符。"}}}}
1
+ {"commands":{"musicjs":{"description":"用 JavaScript 代码演奏旋律","usage":"函数及其参数说明:\n note(tone: number, beats: number, temperament = 12) 创建平均律音符\n tone 音符相对于基准音的偏移(默认情况下,单位为半音)\n beats 音符时长(拍)\n temperament 平均律的音阶数;决定了多少 tone 为一个八度\n noteJust(ratio: number, beats: number) 创建纯律音符\n ratio 音符音高与基准音频率的比值\n beats 音符时长(拍)\n noteHz(frequency: number, beats: number) 创建指定频率音高的音符\n frequency 频率(赫兹)\n beats 音符时长(拍)\n rest(beats: number) 休止\n beats 休止时长(拍)\n变量说明——修改这些变量会影响后续创建音符的属性:\n bpm: Number = 120 每分钟拍数\n 由于历史原因,该变量的初始值是一个可以被隐式转换成数字的函数;\n 对其进行有效的赋值后,才会变成普通数字。\n baseFrequency = 440 基准音频率\n gain = 0.5 音量\n time = 0 当前时间(秒)\n 调用 note、rest 等函数后此变量的值会自动增加。\n 手动减少此值后再添加音符,可以使不同音符同时播放。","messages":{"require-code":"缺少代码。","no-note":"未定义任何音符。"}}}}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@dgck81lnn/koishi-plugin-music",
3
3
  "description": "Synthesize melodies in Koishi",
4
- "version": "0.1.4",
4
+ "version": "0.1.6",
5
5
  "main": "lib/index.js",
6
6
  "typings": "lib/index.d.ts",
7
7
  "files": [