koishi-plugin-ll-mc 1.0.3 → 1.0.4

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.
Files changed (2) hide show
  1. package/lib/index.js +21 -1
  2. package/package.json +45 -45
package/lib/index.js CHANGED
@@ -1958,11 +1958,31 @@ async function apply(ctx, config) {
1958
1958
  (channelInfo[channelId]?.channelName || `群聊${channelId}`),
1959
1959
  // 使用 channelId 作为 RankingData 的 userId 和头像源
1960
1960
  userId: channelId,
1961
- avatar: `https://p.qlogo.cn/gh/${channelId === "#" ? "426230045" : channelId}/${channelId === "#" ? "426230045" : channelId}/100`, // QQ群头像URL格式
1961
+ avatar: groupAvatarUrl(channelId),
1962
1962
  count,
1963
1963
  percentage: calculatePercentage(count, totalCount),
1964
1964
  }));
1965
1965
  }
1966
+ /**
1967
+ * 群头像 URL:
1968
+ * - "#":占位群号
1969
+ * - 数字群号(OneBot/NapCat):p.qlogo.cn/gh/{群号}
1970
+ * - 官机 openid(32位十六进制):官方 API 不提供群头像,尝试与成员头像同源的 qqapp 端点;
1971
+ * 若无效,下载失败会走内置默认头像兜底
1972
+ */
1973
+ function groupAvatarUrl(channelId) {
1974
+ if (channelId === "#" || !channelId) {
1975
+ return `https://p.qlogo.cn/gh/426230045/426230045/100`;
1976
+ }
1977
+ if (/^\d+$/.test(channelId)) {
1978
+ return `https://p.qlogo.cn/gh/${channelId}/${channelId}/100`;
1979
+ }
1980
+ const qqBot = (ctx.bots || []).find(b => b.platform === "qq" && b.config?.id);
1981
+ if (qqBot?.config?.id) {
1982
+ return `https://q.qlogo.cn/qqapp/${qqBot.config.id}/${channelId}/640`;
1983
+ }
1984
+ return `https://p.qlogo.cn/gh/426230045/426230045/100`;
1985
+ }
1966
1986
  // --- 辅助函数:图表生成 ---
1967
1987
  /**
1968
1988
  * 生成图表的静态 CSS 样式。
package/package.json CHANGED
@@ -1,45 +1,45 @@
1
- {
2
- "name": "koishi-plugin-ll-mc",
3
- "description": "消息统计插件(克隆自 message-counter),支持排除指定群聊",
4
- "version": "1.0.3",
5
- "main": "lib/index.js",
6
- "typings": "lib/index.d.ts",
7
- "files": [
8
- "lib",
9
- "assets"
10
- ],
11
- "koishi": {
12
- "description": {
13
- "zh": "消息统计插件:发言排行榜、群排行榜,支持排除指定群聊"
14
- },
15
- "service": {
16
- "required": [
17
- "database",
18
- "cron"
19
- ],
20
- "optional": [
21
- "markdownToImage",
22
- "puppeteer",
23
- "canvas"
24
- ]
25
- }
26
- },
27
- "author": "lee",
28
- "license": "MIT",
29
- "keywords": [
30
- "koishi",
31
- "koishi-plugin",
32
- "message-counter",
33
- "rank"
34
- ],
35
- "peerDependencies": {
36
- "koishi": "^4.18.9"
37
- },
38
- "devDependencies": {
39
- "koishi": "^4.18.11",
40
- "koishi-plugin-cron": "^3.1.0",
41
- "koishi-plugin-markdown-to-image-service": "^1.3.6",
42
- "koishi-plugin-puppeteer": "^3.9.0",
43
- "typescript": "^5.4.0"
44
- }
45
- }
1
+ {
2
+ "name": "koishi-plugin-ll-mc",
3
+ "description": "消息统计插件(克隆自 message-counter),支持排除指定群聊",
4
+ "version": "1.0.4",
5
+ "main": "lib/index.js",
6
+ "typings": "lib/index.d.ts",
7
+ "files": [
8
+ "lib",
9
+ "assets"
10
+ ],
11
+ "koishi": {
12
+ "description": {
13
+ "zh": "消息统计插件:发言排行榜、群排行榜,支持排除指定群聊"
14
+ },
15
+ "service": {
16
+ "required": [
17
+ "database",
18
+ "cron"
19
+ ],
20
+ "optional": [
21
+ "markdownToImage",
22
+ "puppeteer",
23
+ "canvas"
24
+ ]
25
+ }
26
+ },
27
+ "author": "lee",
28
+ "license": "MIT",
29
+ "keywords": [
30
+ "koishi",
31
+ "koishi-plugin",
32
+ "message-counter",
33
+ "rank"
34
+ ],
35
+ "peerDependencies": {
36
+ "koishi": "^4.18.9"
37
+ },
38
+ "devDependencies": {
39
+ "koishi": "^4.18.11",
40
+ "koishi-plugin-cron": "^3.1.0",
41
+ "koishi-plugin-markdown-to-image-service": "^1.3.6",
42
+ "koishi-plugin-puppeteer": "^3.9.0",
43
+ "typescript": "^5.4.0"
44
+ }
45
+ }