koishi-plugin-jryspro-fast 2.2.3 → 2.2.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/CHANGELOG.md CHANGED
@@ -4,48 +4,48 @@
4
4
 
5
5
  ## v1.0.0
6
6
 
7
- * 写好了第一版,发布了插件
7
+ - 写好了第一版,发布了插件
8
8
 
9
9
  ## v1.0.1
10
10
 
11
11
  ### 修改
12
12
 
13
- * 修改了README
13
+ - 修改了README
14
14
 
15
15
  ## v1.0.2
16
16
 
17
17
  ### 新增
18
18
 
19
- * 新增等待提示
19
+ - 新增等待提示
20
20
 
21
21
  ### 修改
22
22
 
23
- * 将“您”改成群名/用户昵称
24
- * 修改必备插件为puppeteer,database为可选。没有puppeteer渲染不了图片,没有database不能限制调用时间。
23
+ - 将“您”改成群名/用户昵称
24
+ - 修改必备插件为puppeteer,database为可选。没有puppeteer渲染不了图片,没有database不能限制调用时间。
25
25
 
26
26
  ## v1.0.3
27
27
 
28
28
  ### 修改
29
29
 
30
- * 修改版本兼容,从v4.11.0往上开始兼容
30
+ - 修改版本兼容,从v4.11.0往上开始兼容
31
31
 
32
32
  ## v1.0.4
33
33
 
34
34
  ### 新增
35
35
 
36
- * 新增图文模式,但是图文模式只能使用我的api,如果有需要可以自己copy源码自行修改,进行二次开发(这一版代码写的有点shi, 见谅)
36
+ - 新增图文模式,但是图文模式只能使用我的api,如果有需要可以自己copy源码自行修改,进行二次开发(这一版代码写的有点shi, 见谅)
37
37
 
38
38
  ## v1.0.5
39
39
 
40
40
  ### 新增
41
41
 
42
- * 新增callme昵称支持
42
+ - 新增callme昵称支持
43
43
 
44
44
  ## v1.0.6
45
45
 
46
46
  ### 新增
47
47
 
48
- * 现在可以修改图文模式的图片api了,但跟渲染图一样只能使用返回图片的api。
48
+ - 现在可以修改图文模式的图片api了,但跟渲染图一样只能使用返回图片的api。
49
49
 
50
50
  > 需要注意的是,api后我加了个v的参数作为时间戳来刷新图片如果您的api有跟v参数冲突的建议换一个api或者二次开发本插件
51
51
 
@@ -53,11 +53,11 @@
53
53
 
54
54
  ### 新增
55
55
 
56
- * 新增 `fortuneApi` 配置
56
+ - 新增 `fortuneApi` 配置
57
57
 
58
58
  ### 调整
59
59
 
60
- * 后端api寄了,现在可以配置运势源的api,如果我的也寄掉了那么请换成你自建的后端或者用别人的后端
60
+ - 后端api寄了,现在可以配置运势源的api,如果我的也寄掉了那么请换成你自建的后端或者用别人的后端
61
61
 
62
62
  > 运势源api仓库[https://github.com/Twiyin0/jryspro-api](https://github.com/Twiyin0/jryspro-api)
63
63
 
@@ -65,25 +65,25 @@
65
65
 
66
66
  ### 修复
67
67
 
68
- * 修改了README
69
- * 不小心把csv文件上传了导致包很大
70
- * 就是删了点有的没的
68
+ - 修改了README
69
+ - 不小心把csv文件上传了导致包很大
70
+ - 就是删了点有的没的
71
71
 
72
72
  ## v1.2.0
73
73
 
74
74
  ### 修复
75
75
 
76
- * 据反映大部分用户无法正常请求api,看了下原因是request已弃用,因此导致的问题
76
+ - 据反映大部分用户无法正常请求api,看了下原因是request已弃用,因此导致的问题
77
77
 
78
78
  ### 修改
79
79
 
80
- * 将request替换成内置的axios
80
+ - 将request替换成内置的axios
81
81
 
82
82
  ## v1.2.1
83
83
 
84
84
  ### 更新
85
85
 
86
- * 更新了有的没的
86
+ - 更新了有的没的
87
87
 
88
88
  ## v1.3.0
89
89
 
@@ -91,156 +91,208 @@
91
91
 
92
92
  ### 更新
93
93
 
94
- * 运势改为文件,无需再使用运势api
95
- * imgApi与subimgApi支持本地文件夹绝对路径,就是说可以随机自己文件夹内的图片了
96
- * 7月16后,本人的图源api不再向外提供,请更换为自己的图源api或文件夹绝对路径
97
- * 自建的运势api和图源api旧版本仍可以使用
94
+ - 运势改为文件,无需再使用运势api
95
+ - imgApi与subimgApi支持本地文件夹绝对路径,就是说可以随机自己文件夹内的图片了
96
+ - 7月16后,本人的图源api不再向外提供,请更换为自己的图源api或文件夹绝对路径
97
+ - 自建的运势api和图源api旧版本仍可以使用
98
98
 
99
99
  ## v1.3.2
100
100
 
101
101
  ### 新增(更新本插件前请务必关闭本插件)
102
+
102
103
  ### 此版本改了配置文件,请更新时停止该插件并删除该插件在配置文件中的配置项!!
103
104
 
104
- * 增加了启用/禁用自动夜间模式开关
105
+ - 增加了启用/禁用自动夜间模式开关
105
106
 
106
107
  ## v1.3.3
107
108
 
108
109
  ### 修复
109
110
 
110
- * 修复图片缓存不清空的问题(注意:只针对?random有效参数)
111
- * 如果你的api地址后不支持?random请不要更新此插件
111
+ - 修复图片缓存不清空的问题(注意:只针对?random有效参数)
112
+ - 如果你的api地址后不支持?random请不要更新此插件
112
113
 
113
114
  ## v1.3.4
114
115
 
115
116
  ### 优化
116
- * 优化图片缓存刷新
117
- * 刷新图片缓存方法:api中 #e# 代表当前unix时间戳
117
+
118
+ - 优化图片缓存刷新
119
+ - 刷新图片缓存方法:api中 #e# 代表当前unix时间戳
118
120
 
119
121
  ## v1.3.5
120
122
 
121
123
  ### 优化
122
- * 获取不到用户id时提示
123
- * 部分session.send替换成return
124
+
125
+ - 获取不到用户id时提示
126
+ - 部分session.send替换成return
124
127
 
125
128
  ## v1.3.6
129
+
126
130
  ### 修改
127
- * !改为==0
128
- * 起猛了,发太快了
131
+
132
+ - !改为==0
133
+ - 起猛了,发太快了
129
134
 
130
135
  ## v1.3.7
136
+
131
137
  ### 修复
132
- * 修复jrys无法在沙盒中运行
133
- * 当无法获取用户id时采用用户名作为今日运势的依据
138
+
139
+ - 修复jrys无法在沙盒中运行
140
+ - 当无法获取用户id时采用用户名作为今日运势的依据
134
141
 
135
142
  ## v1.3.8
143
+
136
144
  ### 适配
137
- * 适配了一下新版本
145
+
146
+ - 适配了一下新版本
138
147
 
139
148
  ## v1.3.10
149
+
140
150
  ### 修复
141
- * 修复了Digest无法更新的问题
151
+
152
+ - 修复了Digest无法更新的问题
142
153
 
143
154
  ## v1.3.11
155
+
144
156
  ### 修复
145
- * 修复了uid无法获取时发生未知错误
157
+
158
+ - 修复了uid无法获取时发生未知错误
146
159
 
147
160
  ## v1.3.12
161
+
148
162
  ### 修复
149
- * 修复了运势有概率不会变化的问题(由于某些原因会有概率无法获取用户UID,目前用固定数值的方法产生运势数组)
163
+
164
+ - 修复了运势有概率不会变化的问题(由于某些原因会有概率无法获取用户UID,目前用固定数值的方法产生运势数组)
150
165
 
151
166
  ## v1.3.13
167
+
152
168
  ### 修复
153
- * 加法换成乘法,这样能保证每次的数值不一样
169
+
170
+ - 加法换成乘法,这样能保证每次的数值不一样
154
171
 
155
172
  ## v1.3.14
173
+
156
174
  ### 修复
157
- * 运势取模不再+1,避免溢出数组
175
+
176
+ - 运势取模不再+1,避免溢出数组
158
177
 
159
178
  ## v1.3.15
179
+
160
180
  ### 修复
161
- * 获取时间戳改为var,const可能会导致时间戳不变化导致运势不变化
181
+
182
+ - 获取时间戳改为var,const可能会导致时间戳不变化导致运势不变化
162
183
 
163
184
  ## v2.0.0
185
+
164
186
  ## UI修改
165
- * 修改了默认模式2,为新版竖屏模式,同时-N(大写)也可以输出新版jrys
187
+
188
+ - 修改了默认模式2,为新版竖屏模式,同时-N(大写)也可以输出新版jrys
189
+
166
190
  ## 说明
167
- * 背景图采用竖屏imgurl
168
- * subimgurl改为可选,不用配置subimgApi也能用jryspro-fast了
191
+
192
+ - 背景图采用竖屏imgurl
193
+ - subimgurl改为可选,不用配置subimgApi也能用jryspro-fast了
169
194
 
170
195
  ## v2.0.2
196
+
171
197
  ## 修复
172
- * 修复了使用.evaluate()函数超时的问题,但是源码内注释保留,为今后做UI渲染提供思路()
198
+
199
+ - 修复了使用.evaluate()函数超时的问题,但是源码内注释保留,为今后做UI渲染提供思路()
173
200
 
174
201
  ## 修改
175
- * 修改了一点小细节
176
- * 注:头像获取不到可能是适配器问题,采用koishi官方API ———— session.author.avatar 来获取的头像
202
+
203
+ - 修改了一点小细节
204
+ - 注:头像获取不到可能是适配器问题,采用koishi官方API ———— session.author.avatar 来获取的头像
177
205
 
178
206
  ## v2.1.0
207
+
179
208
  ## 修复
180
- * 修复了qq适配器无法显示头像的问题
181
- * 修复了直接启用插件会报未知错误
182
- * 修复jrys -i无法使用的问题
209
+
210
+ - 修复了qq适配器无法显示头像的问题
211
+ - 修复了直接启用插件会报未知错误
212
+ - 修复jrys -i无法使用的问题
183
213
 
184
214
  ## 新增
185
- * 如果使用qq适配器请配置adapterqqID配置项
215
+
216
+ - 如果使用qq适配器请配置adapterqqID配置项
186
217
 
187
218
  ## v2.1.3
219
+
188
220
  ## 修复
189
- * 彻底修复截图超时问题
221
+
222
+ - 彻底修复截图超时问题
190
223
 
191
224
  ## v2.1.4
225
+
192
226
  ## 修复
193
- * 修复CDN超时的问题
227
+
228
+ - 修复CDN超时的问题
194
229
 
195
230
  ## v2.1.6
231
+
196
232
  ## 修复
197
- * 修复截图超时的问题
198
- * QQ适配器不需要再配置botid
233
+
234
+ - 修复截图超时的问题
235
+ - QQ适配器不需要再配置botid
199
236
 
200
237
  ## v2.1.8
238
+
201
239
  ## 新增
202
- * 新版渲染支持夜间模式,夜间模式回归啦
203
- * 新增了npmignore,将index.html隐藏防止api泄露
240
+
241
+ - 新版渲染支持夜间模式,夜间模式回归啦
242
+ - 新增了npmignore,将index.html隐藏防止api泄露
204
243
 
205
244
  ## v2.1.9
245
+
206
246
  ### 更新
207
- * 更新了版本号(bushi)
247
+
248
+ - 更新了版本号(bushi)
208
249
 
209
250
  ### 修复
210
- * 修复渲染图片完成后报错的问题
251
+
252
+ - 修复渲染图片完成后报错的问题
211
253
 
212
254
  ## v2.1.10
255
+
213
256
  ### 更新
214
- * 更新了版本号(bushi)
257
+
258
+ - 更新了版本号(bushi)
215
259
 
216
260
  ### 修复
217
- * 上个版本js文件夹没有上传成功
261
+
262
+ - 上个版本js文件夹没有上传成功
218
263
 
219
264
  ## v2.1.12 (此版本有新增配置项)
265
+
220
266
  ### 新增
221
- * 新增图片输出质量配置项,之前渲染图输出的图片都太大了
222
- * 图片输出质量拉到顶时输出png格式,无损
267
+
268
+ - 新增图片输出质量配置项,之前渲染图输出的图片都太大了
269
+ - 图片输出质量拉到顶时输出png格式,无损
223
270
 
224
271
  ## v2.2.0
225
272
 
226
273
  ### 修改
227
274
 
228
- * 修改必备插件为vercelSatoriPngService。没有vercelSatoriPngService渲染不了图片。
275
+ - 修改必备插件为vercelSatoriPngService。没有vercelSatoriPngService渲染不了图片。
229
276
 
230
277
  ## v2.2.2
231
278
 
232
279
  ### 优化
233
280
 
234
- * 图片处理库sharp替换为更好的wasm-vips
235
-
281
+ - 图片处理库sharp替换为更好的wasm-vips
236
282
 
237
283
  ## v2.2.3
238
284
 
239
285
  ### 修改
240
286
 
241
- * 修改必备插件为to-image-service。没有to-image-service渲染不了图片。
287
+ - 修改必备插件为to-image-service。没有to-image-service渲染不了图片。
242
288
 
243
289
  ### 优化
244
290
 
245
- * 样式
246
- * 支持图片质量
291
+ - 样式
292
+ - 支持图片质量
293
+
294
+ ## v2.2.6
295
+
296
+ ### 修复
297
+
298
+ - 加载本地文件不正确
package/README.md CHANGED
@@ -5,8 +5,6 @@
5
5
  jrys plugin for bella
6
6
  ## 注意
7
7
  * 更新前请看[更新日志](https://raw.githubusercontent.com/pgnqukezrdxmhjso/koishi-plugin-jryspro-fast/main/CHANGELOG.md),也许有些版本你并不需要更新
8
- * 如果需要将v1.2.x更新到v1.3.x请先停止本插件再更新,以免koishi炸掉
9
- * v1.3.3(非重要更新) 如果你的图源api地址不支持?random参数,请不要更新此插件
10
8
 
11
9
  ## 使用方法
12
10
  指令: 今日运势
@@ -32,15 +30,15 @@ jrys plugin for bella
32
30
  | `nightauto` | | 是否开启自动夜间模式 |
33
31
  | `nightStart` | | 夜间模式开启时间整点(24时制),一般设置在晚上 |
34
32
  | `nightEnd` | | 夜间模式结束时间整点(24时制),一般设置在早上(需要注意的是,结束时间要小于开启时间,否则启用默认值) |
35
- | `imgApi` |(v1.3.0可用本地文件夹绝对路径)| 图片api地址,仅支持返回图片的api,不支持json等。由于我只制作了竖屏图片适配,建议使用竖屏的图片。在填写时不要把`http(s)://`忘了哦。 |
33
+ | `imgApi` || 图片api地址,仅支持返回图片的api,不支持json等。由于我只制作了竖屏图片适配,建议使用竖屏的图片。在填写时不要把`http(s)://`忘了哦。 |
36
34
  | `waitting` | | 是否开启等待提示,默认开启 |
37
35
  | `defaultMode` | | 默认输出模式,非以下参数默认为`0` |
38
36
  | | `0` | 渲染输出to-image-service渲染输出 |
39
37
  | | `1` | 纯文本输出,仅输出文本 |
40
38
  | | `2` | (默认)新版竖屏模式输出 |
41
39
  | | `3` | 图文输出,文字+图片的输出方式 |
42
- | `subimgApi` |(v1.3.0可用本地文件夹绝对路径)| 图文模式的图片api地址,仅支持返回图片的api,不支持json等。api后我加了?v=的参数用来刷新图片,如果你的api跟v这个参数冲突了可以换一个api或者。在填写时不要把`http(s)://`忘了哦 |
43
- | `fortuneApi` |(v1.3.0前可用)| 运势源api,尽可能用自己的api(我服务器也不是永久的,也可能被打死如果没了你可以选择自建后端然后用自己的api) |
40
+ | `subimgApi` || 图文模式的图片api地址,仅支持返回图片的api,不支持json等。api后我加了?v=的参数用来刷新图片,如果你的api跟v这个参数冲突了可以换一个api或者。在填写时不要把`http(s)://`忘了哦 |
41
+
44
42
 
45
43
  # CHANGELOG
46
44
 
@@ -52,8 +50,7 @@ jrys plugin for bella
52
50
  * 例: https://api.example.com/img?#e# ==等价于== https://api.example.com/img?271878
53
51
  * 例: https://api.example.com/img?type=acc&v=#e# ==等价于== https://api.example.com/img?type=acc&v=271878
54
52
 
55
- 本人的图源api不再向外提供,可以选择随机指定文件夹内的图片。或者其他图源的api(推荐竖屏)
56
- imgApi与subimgApi支持本地文件夹绝对路径和http(s)等网络api
53
+ imgApi与subimgApi支持本地文件夹绝对路径和相对koishi路径和http(s)等网络api
57
54
 
58
55
  # TIP
59
56
  如果没有图片输出可以看看log时不时to-image-service有问题
package/lib/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { Context, Schema } from "koishi";
2
2
  export declare const name = "jryspro-fast";
3
- export declare const usage = "\n## \u66F4\u65B0\u63D2\u4EF6\u524D\u8BF7\u505C\u6B62\u8FD0\u884C\u63D2\u4EF6\n\u63D2\u4EF6\u914D\u7F6E\u9879\u53EF\u80FD\u4F1A\u6709\u6539\u52A8\uFF0C\u4E0D\u505C\u6B62\u63D2\u4EF6\u76F4\u63A5\u66F4\u65B0\u53EF\u80FD\u4F1A\u5BFC\u81F4koishi\u70B8\u6389\n\n## \u4F7F\u7528\u8BF4\u660E\n\n> \u5982\u679C\u4F60\u65E0\u6CD5\u4F7F\u7528\u6B64\u63D2\u4EF6\uFF0C\u8BF7\u68C0\u67E5\n> - 1. (\u4F7F\u7528\u547D\u4EE4\u65F6\u65E0\u53CD\u5E94\uFF0C\u62A5\u9519\u7B49)\u8BF7\u68C0\u67E5\u6307\u4EE4\u662F\u5426\u6709\u51B2\u7A81\u6216\u8005\u662F\u5426\u6B63\u786E\u5B89\u88C5to-image-service\n> - 2. \u63D0\u793A\u201C\u53D1\u751F\u672A\u77E5\u9519\u8BEF\u201D\u53EF\u80FD\u662F\u6CA1\u6709\u83B7\u53D6\u5230\u7FA4\u53CB\u7684uid\uFF0C\u9700\u8981\u5728\u6570\u636E\u5E93\u5185\u5237\u65B0\u4E00\u4E0B\n> - 3. \u201C\u6570\u636E\u51FA\u9519\u201D\u4E4B\u7C7B\u7684\u63D0\u793A\u4E0D\u662F\u672C\u63D2\u4EF6\u7684\u63D0\u793A\uFF0C\u53EF\u80FD\u4F60\u88C5\u4E86\u5176\u4ED6\u63D2\u4EF6\n> - 4. \u542F\u7528\u4E0D\u4E86\u63D2\u4EF6\u3002\u8BF7\u68C0\u67E5koishi\u7248\u672C\uFF0Cto-image-service\u7248\u672C\u7B49\u662F\u5426\u518D\u517C\u5BB9\u8303\u56F4\u5185\uFF0C\u6216\u91CD\u542Fkoishi\uFF0C\u5220\u9664\u6B64\u63D2\u4EF6\u4F9D\u8D56\u518D\u5C1D\u8BD5\u91CD\u88C5\n\n\u968F\u673A\u6587\u4EF6\u5939\u5185\u56FE\u7247\u65F6\u8BF7\u6CE8\u610F\u8DEF\u5F84`C:/user/path/to/`\u4E0D\u8981\u628A\u540E\u9762\u7684/\u5FD8\u4E86\n\n## api\u8BF4\u660E\n* api url\u4EE5 #e# \u7ED3\u5C3E\u53EF\u4EE5\u5728\u672B\u5C3E\u6DFB\u52A0\u66F4\u65B0\u65F6\u95F4\u6233(\u4F8B\u5B50\u540E\u9762\u7B49\u4EF7\u7684\u6570\u5B57\u4E3A\u5F53\u524D\u65F6\u95F4\u6233)\n* \u4F8B: https://api.example.com/img?#e# ==\u7B49\u4EF7\u4E8E== https://api.example.com/img?271878\n* \u4F8B: https://api.example.com/img?type=acc&v=#e# ==\u7B49\u4EF7\u4E8E== https://api.example.com/img?type=acc&v=271878\n\nimgApi\u4E0EsubimgApi\u652F\u6301\u672C\u5730\u6587\u4EF6\u5939\u7EDD\u5BF9\u8DEF\u5F84\u548Chttp(s)\u7B49\u7F51\u7EDCapi\n";
3
+ export declare const usage = "\n## \u66F4\u65B0\u63D2\u4EF6\u524D\u8BF7\u505C\u6B62\u8FD0\u884C\u63D2\u4EF6\n\u63D2\u4EF6\u914D\u7F6E\u9879\u53EF\u80FD\u4F1A\u6709\u6539\u52A8\uFF0C\u4E0D\u505C\u6B62\u63D2\u4EF6\u76F4\u63A5\u66F4\u65B0\u53EF\u80FD\u4F1A\u5BFC\u81F4koishi\u70B8\u6389\n\n## \u4F7F\u7528\u8BF4\u660E\n\n> \u5982\u679C\u4F60\u65E0\u6CD5\u4F7F\u7528\u6B64\u63D2\u4EF6\uFF0C\u8BF7\u68C0\u67E5\n> - 1. (\u4F7F\u7528\u547D\u4EE4\u65F6\u65E0\u53CD\u5E94\uFF0C\u62A5\u9519\u7B49)\u8BF7\u68C0\u67E5\u6307\u4EE4\u662F\u5426\u6709\u51B2\u7A81\u6216\u8005\u662F\u5426\u6B63\u786E\u5B89\u88C5to-image-service\n> - 2. \u63D0\u793A\u201C\u53D1\u751F\u672A\u77E5\u9519\u8BEF\u201D\u53EF\u80FD\u662F\u6CA1\u6709\u83B7\u53D6\u5230\u7FA4\u53CB\u7684uid\uFF0C\u9700\u8981\u5728\u6570\u636E\u5E93\u5185\u5237\u65B0\u4E00\u4E0B\n> - 3. \u201C\u6570\u636E\u51FA\u9519\u201D\u4E4B\u7C7B\u7684\u63D0\u793A\u4E0D\u662F\u672C\u63D2\u4EF6\u7684\u63D0\u793A\uFF0C\u53EF\u80FD\u4F60\u88C5\u4E86\u5176\u4ED6\u63D2\u4EF6\n> - 4. \u542F\u7528\u4E0D\u4E86\u63D2\u4EF6\u3002\u8BF7\u68C0\u67E5koishi\u7248\u672C\uFF0Cto-image-service\u7248\u672C\u7B49\u662F\u5426\u518D\u517C\u5BB9\u8303\u56F4\u5185\uFF0C\u6216\u91CD\u542Fkoishi\uFF0C\u5220\u9664\u6B64\u63D2\u4EF6\u4F9D\u8D56\u518D\u5C1D\u8BD5\u91CD\u88C5\n\n\u968F\u673A\u6587\u4EF6\u5939\u5185\u56FE\u7247\u65F6\u8BF7\u6CE8\u610F\u8DEF\u5F84`C:/user/path/to/`\u4E0D\u8981\u628A\u540E\u9762\u7684/\u5FD8\u4E86\n\n## api\u8BF4\u660E\n* api url\u4EE5 #e# \u7ED3\u5C3E\u53EF\u4EE5\u5728\u672B\u5C3E\u6DFB\u52A0\u66F4\u65B0\u65F6\u95F4\u6233(\u4F8B\u5B50\u540E\u9762\u7B49\u4EF7\u7684\u6570\u5B57\u4E3A\u5F53\u524D\u65F6\u95F4\u6233)\n* \u4F8B: https://api.example.com/img?#e# ==\u7B49\u4EF7\u4E8E== https://api.example.com/img?271878\n* \u4F8B: https://api.example.com/img?type=acc&v=#e# ==\u7B49\u4EF7\u4E8E== https://api.example.com/img?type=acc&v=271878\n\nimgApi\u4E0EsubimgApi\u652F\u6301\u672C\u5730\u6587\u4EF6\u5939\u7EDD\u5BF9\u8DEF\u5F84\u548C\u76F8\u5BF9koishi\u8DEF\u5F84\u548Chttp(s)\u7B49\u7F51\u7EDCapi\n";
4
4
  export interface Config {
5
5
  interval: number;
6
6
  nightauto: boolean;
package/lib/index.js CHANGED
@@ -28,19 +28,20 @@ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__ge
28
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
29
 
30
30
  // src/index.ts
31
- var src_exports = {};
32
- __export(src_exports, {
31
+ var index_exports = {};
32
+ __export(index_exports, {
33
33
  apply: () => apply,
34
34
  inject: () => inject,
35
35
  name: () => name,
36
36
  schema: () => schema,
37
37
  usage: () => usage
38
38
  });
39
- module.exports = __toCommonJS(src_exports);
39
+ module.exports = __toCommonJS(index_exports);
40
40
  var import_node_fs = __toESM(require("node:fs"));
41
41
  var import_node_path = __toESM(require("node:path"));
42
42
  var import_node_crypto = __toESM(require("node:crypto"));
43
43
  var import_koishi = require("koishi");
44
+ var import_koishi_plugin_rzgtboeyndxsklmq_commons = require("koishi-plugin-rzgtboeyndxsklmq-commons");
44
45
  var name = "jryspro-fast";
45
46
  var logger = new import_koishi.Logger(name);
46
47
  var usage = `
@@ -62,7 +63,7 @@ var usage = `
62
63
  * 例: https://api.example.com/img?#e# ==等价于== https://api.example.com/img?271878
63
64
  * 例: https://api.example.com/img?type=acc&v=#e# ==等价于== https://api.example.com/img?type=acc&v=271878
64
65
 
65
- imgApi与subimgApi支持本地文件夹绝对路径和http(s)等网络api
66
+ imgApi与subimgApi支持本地文件夹绝对路径和相对koishi路径和http(s)等网络api
66
67
  `;
67
68
  var schema = import_koishi.Schema.object({
68
69
  interval: import_koishi.Schema.number().default(3e4).description("指令调用间隔(单位ms)[需要加载数据库]"),
@@ -85,7 +86,7 @@ var schema = import_koishi.Schema.object({
85
86
  subimgApi: import_koishi.Schema.string().role("link").description(
86
87
  "图文模式图片的api或文件夹,仅支持返回图片的api,不要忘记http(s)://"
87
88
  ),
88
- avatarUrl: import_koishi.Schema.string().role("link").description("默认头像URL(https?://或者file:///)")
89
+ avatarUrl: import_koishi.Schema.string().role("link").description("默认头像URL(https?://或者图片文件路径)")
89
90
  });
90
91
  var inject = ["toImageService", "database"];
91
92
  async function apply(ctx, config) {
@@ -134,24 +135,14 @@ async function apply(ctx, config) {
134
135
  if (/^https?:\/\//i.test(config.imgApi)) {
135
136
  backgroundUrl = config.imgApi.replace(/#e#$/gi, eTime);
136
137
  } else {
137
- backgroundUrl = "file:///" + import_node_path.default.resolve(
138
- __dirname,
139
- config.imgApi,
140
- "." + import_node_path.default.sep,
141
- import_koishi.Random.pick(await getFolderImg(config.imgApi))
142
- );
138
+ backgroundUrl = "file:///" + import_koishi.Random.pick(await getFolderImg(config.imgApi));
143
139
  }
144
140
  let subImgUrl;
145
141
  if (config.subimgApi) {
146
142
  if (/^https?:\/\//i.test(config.subimgApi)) {
147
- subImgUrl = config.imgApi.replace(/#e#$/gi, eTime);
143
+ subImgUrl = config.subimgApi.replace(/#e#$/gi, eTime);
148
144
  } else {
149
- subImgUrl = "file:///" + import_node_path.default.resolve(
150
- __dirname,
151
- config.subimgApi,
152
- "." + import_node_path.default.sep,
153
- import_koishi.Random.pick(await getFolderImg(config.subimgApi))
154
- );
145
+ subImgUrl = "file:///" + import_koishi.Random.pick(await getFolderImg(config.subimgApi));
155
146
  }
156
147
  }
157
148
  const dJson = getJrys(session);
@@ -270,23 +261,12 @@ async function apply(ctx, config) {
270
261
  }
271
262
  });
272
263
  async function htmlToImg(html, width, height) {
273
- const reactElement = ctx.toImageService.toReactElement.htmlToReactElement(html);
274
- const svg = await ctx.toImageService.reactElementToSvg.satori(
275
- reactElement,
276
- {
277
- width,
278
- height
279
- }
280
- );
281
- if (config.imgQuality === 100) {
282
- return await ctx.toImageService.svgToImage.vips(svg, {
283
- format: "png"
284
- });
285
- }
286
- return await ctx.toImageService.svgToImage.vips(svg, {
287
- format: "jpeg",
288
- options: {
289
- Q: config.imgQuality
264
+ return await ctx.toImageService.htmlToImage(html, {
265
+ width,
266
+ height,
267
+ ...config.imgQuality === 100 ? {} : {
268
+ format: "jpeg",
269
+ quality: config.imgQuality
290
270
  }
291
271
  });
292
272
  }
@@ -328,41 +308,38 @@ async function apply(ctx, config) {
328
308
  let imgData;
329
309
  if (/^https?:/i.test(url)) {
330
310
  imgData = Buffer.from(await ctx.http.get(url));
331
- } else if (/^file:/i.test(url)) {
332
- imgData = await import_node_fs.default.promises.readFile(url.replace(/^file:\/+/, ""));
333
311
  } else {
334
- logger.error("未知url类型");
335
- throw "渲染失败,不知道发生了啥";
312
+ url = handleFilePath(url.replace(/^file:\/+/, ""));
313
+ imgData = await import_node_fs.default.promises.readFile(url);
336
314
  }
337
315
  const imgType = await fileType.fileTypeFromBuffer(imgData);
338
- const vips = ctx.toImageService.toImageBase.getVips();
316
+ const sharp = await ctx.toImageService.sharpRenderer.getSharp();
339
317
  let img;
340
318
  let metaData;
341
319
  const touchImg = /* @__PURE__ */ __name(() => {
342
320
  if (!img) {
343
- img = vips.Image.newFromBuffer(imgData);
321
+ img = sharp(imgData);
344
322
  }
345
323
  }, "touchImg");
346
324
  if (needMetadata) {
347
325
  touchImg();
326
+ const metadata = await img.metadata();
348
327
  metaData = {
349
- width: img.width,
350
- height: img.height
328
+ width: metadata.width,
329
+ height: metadata.height
351
330
  };
352
331
  }
353
332
  if (cover) {
354
- img = vips.Image.thumbnailBuffer(imgData, cover.width, {
355
- height: cover.height,
356
- crop: vips.Interesting.centre
357
- });
333
+ touchImg();
334
+ img.resize(cover.width, cover.height);
358
335
  if (imgType.ext !== "webp") {
359
- imgData = Buffer.from(img.pngsaveBuffer());
336
+ imgData = Buffer.from(await img.toBuffer());
360
337
  }
361
338
  }
362
339
  let mime = imgType.mime;
363
340
  if (imgType.ext === "webp") {
364
341
  touchImg();
365
- imgData = Buffer.from(img.pngsaveBuffer());
342
+ imgData = Buffer.from(await img.png().toBuffer());
366
343
  mime = "image/png";
367
344
  }
368
345
  return {
@@ -371,31 +348,17 @@ async function apply(ctx, config) {
371
348
  };
372
349
  }
373
350
  __name(downloadUrl, "downloadUrl");
351
+ function handleFilePath(filePath) {
352
+ return import_node_fs.default.existsSync(filePath) ? filePath : import_node_path.default.relative(ctx.baseDir, filePath);
353
+ }
354
+ __name(handleFilePath, "handleFilePath");
355
+ async function getFolderImg(folder) {
356
+ let files = await import_koishi_plugin_rzgtboeyndxsklmq_commons.Files.readDirFiles(handleFilePath(folder));
357
+ return files.filter((f) => /\.(png|jpg|jpeg|webp|svg)$/i.test(f));
358
+ }
359
+ __name(getFolderImg, "getFolderImg");
374
360
  }
375
361
  __name(apply, "apply");
376
- async function getFolderImg(folder) {
377
- return readFileNames(
378
- folder,
379
- (fileName) => /\.(png|jpg|jpeg|webp|svg)$/i.test(fileName)
380
- );
381
- }
382
- __name(getFolderImg, "getFolderImg");
383
- function readFileNames(dirPath, verify, basePath = "") {
384
- let filenames = [];
385
- const files = import_node_fs.default.readdirSync(dirPath);
386
- files.forEach((filename) => {
387
- const fullPath = import_node_path.default.join(dirPath, filename);
388
- if (import_node_fs.default.statSync(fullPath).isDirectory()) {
389
- filenames.push(
390
- ...readFileNames(fullPath, verify, import_node_path.default.join(basePath, filename))
391
- );
392
- } else if (verify(filename)) {
393
- filenames.push(import_node_path.default.join(basePath, filename));
394
- }
395
- });
396
- return filenames;
397
- }
398
- __name(readFileNames, "readFileNames");
399
362
  // Annotate the CommonJS export names for ESM import in node:
400
363
  0 && (module.exports = {
401
364
  apply,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-jryspro-fast",
3
- "version": "2.2.3",
3
+ "version": "2.2.6",
4
4
  "main": "lib/index.js",
5
5
  "typings": "lib/index.d.ts",
6
6
  "homepage": "https://github.com/pgnqukezrdxmhjso/koishi-plugin-jryspro-fast",
@@ -10,9 +10,7 @@
10
10
  },
11
11
  "scripts": {
12
12
  "build": "cd ../../ && yarn build jryspro-fast",
13
- "pub": "cd ../../ && yarn pub jryspro-fast",
14
- "fastPub": "cd ../../ && yarn bump -3 jryspro-fast && yarn build jryspro-fast && yarn pub jryspro-fast",
15
- "test": "node src/test/test.js"
13
+ "up": "npx npm-check -u --no-color"
16
14
  },
17
15
  "contributors": [
18
16
  "Twiyin0 <twiyin0@outlook.com>",
@@ -52,9 +50,11 @@
52
50
  "koishi": "^4.18.10"
53
51
  },
54
52
  "dependencies": {
55
- "file-type": "^21.3.0"
53
+ "file-type": "^22.0.0",
54
+ "koishi-plugin-rzgtboeyndxsklmq-commons": "^1.1.0"
56
55
  },
57
56
  "devDependencies": {
58
- "koishi-plugin-to-image-service": "^0.1.0"
57
+ "koishi-plugin-rate-limit": "^2.0.4",
58
+ "koishi-plugin-to-image-service": "^1.6.2"
59
59
  }
60
60
  }