koishi-plugin-stock 1.0.9 → 1.0.11
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/README.md +12 -0
- package/lib/index.d.ts +6 -0
- package/lib/index.js +64 -11
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,12 @@ npm install koishi-plugin-stock
|
|
|
28
28
|
- `limitUpBoardBlacklist`: 涨停看板指令黑名单用户ID数组
|
|
29
29
|
- `stockSelectionBlacklist`: 选股指令黑名单用户ID数组
|
|
30
30
|
- `rideBlacklist`: 骑指令黑名单用户ID数组
|
|
31
|
+
- `allCommandsChannelBlacklist`: 全部指令黑名单频道ID数组
|
|
32
|
+
- `activeMarketCapChannelBlacklist`: 活跃市值指令黑名单频道ID数组
|
|
33
|
+
- `stockAlertChannelBlacklist`: 异动指令黑名单频道ID数组
|
|
34
|
+
- `limitUpBoardChannelBlacklist`: 涨停看板指令黑名单频道ID数组
|
|
35
|
+
- `stockSelectionChannelBlacklist`: 选股指令黑名单频道ID数组
|
|
36
|
+
- `rideChannelBlacklist`: 骑指令黑名单频道ID数组
|
|
31
37
|
|
|
32
38
|
## 使用
|
|
33
39
|
|
|
@@ -41,6 +47,12 @@ npm install koishi-plugin-stock
|
|
|
41
47
|
|
|
42
48
|
## 更新日志
|
|
43
49
|
|
|
50
|
+
### v1.0.11
|
|
51
|
+
- 添加了频道/群聊黑名单功能,支持按频道ID限制指令使用
|
|
52
|
+
|
|
53
|
+
### v1.0.10
|
|
54
|
+
- 修复了"骑"指令,使用本地图片路径并返回base64编码的图片
|
|
55
|
+
|
|
44
56
|
### v1.0.9
|
|
45
57
|
- 添加了"骑"指令,可返回本地图片
|
|
46
58
|
|
package/lib/index.d.ts
CHANGED
|
@@ -6,6 +6,12 @@ export interface Config {
|
|
|
6
6
|
stockSelectionBlacklist?: string[];
|
|
7
7
|
rideBlacklist?: string[];
|
|
8
8
|
allCommandsBlacklist?: string[];
|
|
9
|
+
activeMarketCapChannelBlacklist?: string[];
|
|
10
|
+
stockAlertChannelBlacklist?: string[];
|
|
11
|
+
limitUpBoardChannelBlacklist?: string[];
|
|
12
|
+
stockSelectionChannelBlacklist?: string[];
|
|
13
|
+
rideChannelBlacklist?: string[];
|
|
14
|
+
allCommandsChannelBlacklist?: string[];
|
|
9
15
|
}
|
|
10
16
|
export declare const Config: Schema<Config>;
|
|
11
17
|
export declare function apply(ctx: Context, config: Config): void;
|
package/lib/index.js
CHANGED
|
@@ -10,12 +10,19 @@ exports.Config = koishi_1.Schema.object({
|
|
|
10
10
|
limitUpBoardBlacklist: koishi_1.Schema.array(String).description('涨停看板指令黑名单用户ID'),
|
|
11
11
|
stockSelectionBlacklist: koishi_1.Schema.array(String).description('选股指令黑名单用户ID'),
|
|
12
12
|
rideBlacklist: koishi_1.Schema.array(String).description('骑指令黑名单用户ID'),
|
|
13
|
+
allCommandsChannelBlacklist: koishi_1.Schema.array(String).description('全部指令黑名单频道ID'),
|
|
14
|
+
activeMarketCapChannelBlacklist: koishi_1.Schema.array(String).description('活跃市值指令黑名单频道ID'),
|
|
15
|
+
stockAlertChannelBlacklist: koishi_1.Schema.array(String).description('异动指令黑名单频道ID'),
|
|
16
|
+
limitUpBoardChannelBlacklist: koishi_1.Schema.array(String).description('涨停看板指令黑名单频道ID'),
|
|
17
|
+
stockSelectionChannelBlacklist: koishi_1.Schema.array(String).description('选股指令黑名单频道ID'),
|
|
18
|
+
rideChannelBlacklist: koishi_1.Schema.array(String).description('骑指令黑名单频道ID'),
|
|
13
19
|
});
|
|
14
20
|
function apply(ctx, config) {
|
|
15
|
-
//
|
|
21
|
+
// 检查用户或频道是否在特定指令的黑名单中
|
|
16
22
|
function isUserInSpecificBlacklist(session, commandName) {
|
|
17
23
|
const userId = session.userId;
|
|
18
|
-
|
|
24
|
+
const channelId = session.channelId;
|
|
25
|
+
// 检查特定指令的用户黑名单
|
|
19
26
|
switch (commandName) {
|
|
20
27
|
case '活跃市值':
|
|
21
28
|
if (config.activeMarketCapBlacklist?.includes(userId)) {
|
|
@@ -43,10 +50,42 @@ function apply(ctx, config) {
|
|
|
43
50
|
}
|
|
44
51
|
break;
|
|
45
52
|
}
|
|
46
|
-
//
|
|
53
|
+
// 检查特定指令的频道黑名单
|
|
54
|
+
switch (commandName) {
|
|
55
|
+
case '活跃市值':
|
|
56
|
+
if (config.activeMarketCapChannelBlacklist?.includes(channelId)) {
|
|
57
|
+
return true;
|
|
58
|
+
}
|
|
59
|
+
break;
|
|
60
|
+
case '异动':
|
|
61
|
+
if (config.stockAlertChannelBlacklist?.includes(channelId)) {
|
|
62
|
+
return true;
|
|
63
|
+
}
|
|
64
|
+
break;
|
|
65
|
+
case '涨停看板':
|
|
66
|
+
if (config.limitUpBoardChannelBlacklist?.includes(channelId)) {
|
|
67
|
+
return true;
|
|
68
|
+
}
|
|
69
|
+
break;
|
|
70
|
+
case '选股':
|
|
71
|
+
if (config.stockSelectionChannelBlacklist?.includes(channelId)) {
|
|
72
|
+
return true;
|
|
73
|
+
}
|
|
74
|
+
break;
|
|
75
|
+
case '骑':
|
|
76
|
+
if (config.rideChannelBlacklist?.includes(channelId)) {
|
|
77
|
+
return true;
|
|
78
|
+
}
|
|
79
|
+
break;
|
|
80
|
+
}
|
|
81
|
+
// 检查全局用户黑名单
|
|
47
82
|
if (config.allCommandsBlacklist?.includes(userId)) {
|
|
48
83
|
return true;
|
|
49
84
|
}
|
|
85
|
+
// 检查全局频道黑名单
|
|
86
|
+
if (config.allCommandsChannelBlacklist?.includes(channelId)) {
|
|
87
|
+
return true;
|
|
88
|
+
}
|
|
50
89
|
return false;
|
|
51
90
|
}
|
|
52
91
|
// 监听活跃市值命令
|
|
@@ -161,10 +200,17 @@ function apply(ctx, config) {
|
|
|
161
200
|
return '您已被加入黑名单,无法使用此功能。';
|
|
162
201
|
}
|
|
163
202
|
try {
|
|
164
|
-
//
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
|
|
203
|
+
// 读取本地图片文件并转换为base64
|
|
204
|
+
const fs = require('fs').promises;
|
|
205
|
+
const path = require('path');
|
|
206
|
+
// 构建图片的绝对路径
|
|
207
|
+
const imagePath = path.resolve(__dirname, '../images/qi.jpeg');
|
|
208
|
+
// 读取图片文件
|
|
209
|
+
const imageData = await fs.readFile(imagePath);
|
|
210
|
+
// 将图片数据转换为base64编码
|
|
211
|
+
const base64Image = imageData.toString('base64');
|
|
212
|
+
// 返回base64编码的图片
|
|
213
|
+
return `<img src="data:image/jpeg;base64,${base64Image}" />`;
|
|
168
214
|
}
|
|
169
215
|
catch (error) {
|
|
170
216
|
console.error('获取骑图片失败:', error);
|
|
@@ -279,10 +325,17 @@ function apply(ctx, config) {
|
|
|
279
325
|
return '您已被加入黑名单,无法使用此功能。';
|
|
280
326
|
}
|
|
281
327
|
try {
|
|
282
|
-
//
|
|
283
|
-
const
|
|
284
|
-
|
|
285
|
-
|
|
328
|
+
// 读取本地图片文件并转换为base64
|
|
329
|
+
const fs = require('fs').promises;
|
|
330
|
+
const path = require('path');
|
|
331
|
+
// 构建图片的绝对路径
|
|
332
|
+
const imagePath = path.resolve(__dirname, '../images/qi.jpeg');
|
|
333
|
+
// 读取图片文件
|
|
334
|
+
const imageData = await fs.readFile(imagePath);
|
|
335
|
+
// 将图片数据转换为base64编码
|
|
336
|
+
const base64Image = imageData.toString('base64');
|
|
337
|
+
// 返回base64编码的图片
|
|
338
|
+
return `<img src="data:image/jpeg;base64,${base64Image}" />`;
|
|
286
339
|
}
|
|
287
340
|
catch (error) {
|
|
288
341
|
console.error('获取骑图片失败:', error);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "koishi-plugin-stock",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.11",
|
|
4
4
|
"description": "A Koishi plugin that fetches stock data and provides market analysis, including active market cap, stock alerts, limit-up board, and stock selection features with configurable blacklists for each command.",
|
|
5
5
|
"main": "lib/index.js",
|
|
6
6
|
"typings": "lib/index.d.ts",
|