koishi-plugin-steam-info-check 1.0.10 → 1.1.0

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 (32) hide show
  1. package/dist/index.js +59 -56
  2. package/nonebot-plugin-steam-info-main/.github/actions/setup-python/action.yml +21 -0
  3. package/nonebot-plugin-steam-info-main/.github/workflows/release.yml +37 -0
  4. package/nonebot-plugin-steam-info-main/LICENSE +21 -0
  5. package/nonebot-plugin-steam-info-main/README.md +117 -0
  6. package/nonebot-plugin-steam-info-main/fonts/MiSans-Bold.ttf +0 -0
  7. package/nonebot-plugin-steam-info-main/fonts/MiSans-Light.ttf +0 -0
  8. package/nonebot-plugin-steam-info-main/fonts/MiSans-Regular.ttf +0 -0
  9. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/__init__.py +487 -0
  10. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/config.py +19 -0
  11. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/data_source.py +264 -0
  12. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/draw.py +921 -0
  13. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/models.py +82 -0
  14. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/res/bg_dots.png +0 -0
  15. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/res/busy.png +0 -0
  16. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/res/default_achievement_image.png +0 -0
  17. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/res/default_header_image.jpg +0 -0
  18. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/res/friends_search.png +0 -0
  19. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/res/gaming.png +0 -0
  20. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/res/parent_status.png +0 -0
  21. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/res/unknown_avatar.jpg +0 -0
  22. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/res/zzz_gaming.png +0 -0
  23. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/res/zzz_online.png +0 -0
  24. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/steam.py +259 -0
  25. package/nonebot-plugin-steam-info-main/nonebot_plugin_steam_info/utils.py +112 -0
  26. package/nonebot-plugin-steam-info-main/pdm.lock +966 -0
  27. package/nonebot-plugin-steam-info-main/preview.png +0 -0
  28. package/nonebot-plugin-steam-info-main/preview_1.png +0 -0
  29. package/nonebot-plugin-steam-info-main/preview_2.png +0 -0
  30. package/nonebot-plugin-steam-info-main/pyproject.toml +29 -0
  31. package/package.json +1 -1
  32. package/src/index.ts +42 -58
@@ -0,0 +1,29 @@
1
+ [project]
2
+ name = "nonebot-plugin-steam-info"
3
+ version = "1.3.5"
4
+ description = "Steam 好友状态播报 NoneBot 插件"
5
+ authors = [
6
+ {name = "zhaomaoniu", email = "2667292003@qq.com"},
7
+ ]
8
+ dependencies = [
9
+ "nonebot2>=2.2.0",
10
+ "nonebot-plugin-alconna>=0.54.2",
11
+ "Pillow>=10.2.0",
12
+ "nonebot-plugin-apscheduler>=0.4.0",
13
+ "nonebot-plugin-localstore>=0.6.0",
14
+ "httpx<0.28.0,>=0.27.0",
15
+ "numpy>=1.24.4",
16
+ "beautifulsoup4>=4.12.3",
17
+ "pytz>=2024.2",
18
+ ]
19
+ requires-python = ">=3.9"
20
+ readme = "README.md"
21
+ license = {text = "MIT"}
22
+
23
+ [build-system]
24
+ requires = ["pdm-backend"]
25
+ build-backend = "pdm.backend"
26
+
27
+
28
+ [tool.pdm]
29
+ distribution = true
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "koishi-plugin-steam-info-check",
3
- "version": "1.0.10",
3
+ "version": "1.1.0",
4
4
  "description": "Steam friends status broadcast plugin for Koishi",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
package/src/index.ts CHANGED
@@ -321,62 +321,7 @@ async function ensureChannelMeta(ctx: Context, session: Session) {
321
321
  }
322
322
  // OneBot 群名补充
323
323
  if (!name && session.platform?.includes('onebot') && session.bot?.internal?.getGroupInfo) {
324
- // 柔性尝试多种参数传递方式,记录每次调用结果以便定位 napcat/onebot 的参数格式差异
325
- const argVariants = [
326
- { group_id: channelId },
327
- { group_id: { group_id: channelId } },
328
- { group_id: Number(channelId) },
329
- { group_id: { group_id: Number(channelId) } },
330
- ]
331
-
332
- // 先尝试对象参数变体
333
- for (const args of argVariants) {
334
- try {
335
- logger.error(`getGroupInfo 尝试 args=${JSON.stringify(args)}`)
336
- const info = await session.bot.internal.getGroupInfo(args)
337
- logger.error(`getGroupInfo 返回: ${JSON.stringify(info)}`)
338
-
339
- if (!info) continue
340
-
341
- // 支持多种返回结构:直接 group_name、data.group_name(napcat)、或嵌套情况
342
- if (info.group_name) {
343
- name = info.group_name
344
- break
345
- }
346
- if (info.data && info.data.group_name) {
347
- name = info.data.group_name
348
- break
349
- }
350
- if (info.data && info.data.group && info.data.group.group_name) {
351
- name = info.data.group.group_name
352
- break
353
- }
354
-
355
- // 某些实现会把返回包在 ret.data 或直接在 ret
356
- if (info.ret && info.ret.data && info.ret.data.group_name) {
357
- name = info.ret.data.group_name
358
- break
359
- }
360
-
361
- // 如果未识别结构,记录并继续尝试下一个参数形态
362
- logger.error('getGroupInfo 返回了未识别结构(尝试 参数:' + JSON.stringify(args) + '): ' + JSON.stringify(info) + ' EEE')
363
- } catch (err) {
364
- // 记录详细错误以便分析 retcode/args
365
- try {
366
- logger.error('getGroupInfo 调用失败,args=' + JSON.stringify(args) + ',错误:' + String(err) + ' EEE')
367
- // 如果错误信息里包含 server-side 的 args 表示 RPC 层可能对参数进行了二次包装,记录原始错误便于排查
368
- if (err && (err as any).message) {
369
- logger.error('getGroupInfo 原始错误信息: ' + String((err as any).message))
370
- }
371
- } catch (e) {
372
- logger.error('getGroupInfo 调用失败但记录 args 时出错:' + String(e) + ' EEE')
373
- }
374
- // 如果错误中包含 retcode,记录方便排查
375
- // 继续尝试下一个参数变体
376
- }
377
- }
378
-
379
- // 再尝试直接传入原始值(避免内部框架二次封装)
324
+ // 先尝试原始(primitive)参数,许多 adapter/napcat 期望直接的字符串或数字
380
325
  const primitiveVariants = [channelId, Number(channelId)]
381
326
  for (const arg of primitiveVariants) {
382
327
  try {
@@ -386,9 +331,49 @@ async function ensureChannelMeta(ctx: Context, session: Session) {
386
331
  if (info) {
387
332
  if ((info as any).group_name) { name = (info as any).group_name; break }
388
333
  if ((info as any).data && (info as any).data.group_name) { name = (info as any).data.group_name; break }
334
+ if ((info as any).data && (info as any).data.group && (info as any).data.group.group_name) { name = (info as any).data.group.group_name; break }
335
+ if ((info as any).ret && (info as any).ret.data && (info as any).ret.data.group_name) { name = (info as any).ret.data.group_name; break }
389
336
  }
390
337
  } catch (err) {
391
338
  logger.error('getGroupInfo 原始参数调用失败,arg=' + JSON.stringify(arg) + ',错误:' + String(err) + ' EEE')
339
+ if (err && (err as any).message) {
340
+ logger.error('getGroupInfo 原始错误信息: ' + String((err as any).message))
341
+ }
342
+ }
343
+ }
344
+
345
+ // 如果 primitive 未成功,再尝试对象参数包裹形式
346
+ if (!name) {
347
+ const argVariants = [
348
+ { group_id: channelId },
349
+ { group_id: { group_id: channelId } },
350
+ { group_id: Number(channelId) },
351
+ { group_id: { group_id: Number(channelId) } },
352
+ ]
353
+ for (const args of argVariants) {
354
+ try {
355
+ logger.error(`getGroupInfo 尝试 args=${JSON.stringify(args)}`)
356
+ const info = await session.bot.internal.getGroupInfo(args)
357
+ logger.error(`getGroupInfo 返回: ${JSON.stringify(info)}`)
358
+
359
+ if (!info) continue
360
+
361
+ if ((info as any).group_name) { name = (info as any).group_name; break }
362
+ if ((info as any).data && (info as any).data.group_name) { name = (info as any).data.group_name; break }
363
+ if ((info as any).data && (info as any).data.group && (info as any).data.group.group_name) { name = (info as any).data.group.group_name; break }
364
+ if ((info as any).ret && (info as any).ret.data && (info as any).ret.data.group_name) { name = (info as any).ret.data.group_name; break }
365
+
366
+ logger.error('getGroupInfo 返回了未识别结构(尝试 参数:' + JSON.stringify(args) + '): ' + JSON.stringify(info) + ' EEE')
367
+ } catch (err) {
368
+ try {
369
+ logger.error('getGroupInfo 调用失败,args=' + JSON.stringify(args) + ',错误:' + String(err) + ' EEE')
370
+ if (err && (err as any).message) {
371
+ logger.error('getGroupInfo 原始错误信息: ' + String((err as any).message))
372
+ }
373
+ } catch (e) {
374
+ logger.error('getGroupInfo 调用失败但记录 args 时出错:' + String(e) + ' EEE')
375
+ }
376
+ }
392
377
  }
393
378
  }
394
379
 
@@ -467,11 +452,10 @@ async function broadcast(ctx: Context, config: Config) {
467
452
  const newGame = current.gameextrainfo
468
453
  const name = bind.nickname || current.personaname
469
454
 
455
+ // 只在玩家开始游戏或从一个游戏切换到另一个游戏时推送
470
456
  if (newGame && !oldGame) {
471
457
  msgs.push(`${name} 开始玩 ${newGame} 了`)
472
458
  startGamingPlayers.push({ ...current, nickname: bind.nickname })
473
- } else if (!newGame && oldGame) {
474
- msgs.push(`${name} 玩了 ${oldGame} 后不玩了`)
475
459
  } else if (newGame && oldGame && newGame !== oldGame) {
476
460
  msgs.push(`${name} 停止玩 ${oldGame},开始玩 ${newGame} 了`)
477
461
  }