@zhin.js/plugin-lottery 1.1.9 → 1.1.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.
Files changed (93) hide show
  1. package/README.md +8 -0
  2. package/commands/lottery/[[game]]/index.js +5 -4
  3. package/commands/lottery/[[game]]/index.ts +5 -4
  4. package/commands/lottery-backtest/[[game]]/index.js +9 -4
  5. package/commands/lottery-backtest/[[game]]/index.ts +8 -4
  6. package/commands/lottery-history/[game]/index.js +6 -4
  7. package/commands/lottery-history/[game]/index.ts +6 -4
  8. package/commands/lottery-stats/[game]/index.js +11 -6
  9. package/commands/lottery-stats/[game]/index.ts +11 -5
  10. package/commands/lottery-today/index.js +8 -4
  11. package/commands/lottery-today/index.ts +8 -3
  12. package/commands/lottery-train/[[game]]/index.js +4 -3
  13. package/commands/lottery-train/[[game]]/index.ts +4 -3
  14. package/lib/command-helpers.d.ts +2 -1
  15. package/lib/command-helpers.d.ts.map +1 -1
  16. package/lib/command-helpers.js +2 -1
  17. package/lib/command-helpers.js.map +1 -1
  18. package/lib/evaluate/backtest.d.ts +3 -2
  19. package/lib/evaluate/backtest.d.ts.map +1 -1
  20. package/lib/evaluate/backtest.js +12 -11
  21. package/lib/evaluate/backtest.js.map +1 -1
  22. package/lib/evaluate/tracker.d.ts +2 -1
  23. package/lib/evaluate/tracker.d.ts.map +1 -1
  24. package/lib/evaluate/tracker.js +9 -8
  25. package/lib/evaluate/tracker.js.map +1 -1
  26. package/lib/evaluate/train-weights.d.ts +3 -2
  27. package/lib/evaluate/train-weights.d.ts.map +1 -1
  28. package/lib/evaluate/train-weights.js +12 -11
  29. package/lib/evaluate/train-weights.js.map +1 -1
  30. package/lib/games/kl8-groups.d.ts +2 -0
  31. package/lib/games/kl8-groups.d.ts.map +1 -1
  32. package/lib/games/kl8-groups.js +2 -1
  33. package/lib/games/kl8-groups.js.map +1 -1
  34. package/lib/i18n.d.ts +2 -0
  35. package/lib/i18n.d.ts.map +1 -0
  36. package/lib/i18n.js +222 -0
  37. package/lib/i18n.js.map +1 -0
  38. package/lib/lottery-tool-handlers.d.ts +4 -3
  39. package/lib/lottery-tool-handlers.d.ts.map +1 -1
  40. package/lib/lottery-tool-handlers.js +12 -7
  41. package/lib/lottery-tool-handlers.js.map +1 -1
  42. package/lib/pipeline.d.ts +3 -1
  43. package/lib/pipeline.d.ts.map +1 -1
  44. package/lib/pipeline.js +9 -7
  45. package/lib/pipeline.js.map +1 -1
  46. package/lib/recommend/game-pick.d.ts +4 -2
  47. package/lib/recommend/game-pick.d.ts.map +1 -1
  48. package/lib/recommend/game-pick.js +39 -28
  49. package/lib/recommend/game-pick.js.map +1 -1
  50. package/lib/recommend/report.d.ts +4 -2
  51. package/lib/recommend/report.d.ts.map +1 -1
  52. package/lib/recommend/report.js +17 -10
  53. package/lib/recommend/report.js.map +1 -1
  54. package/lib/runtime-state.d.ts +2 -0
  55. package/lib/runtime-state.d.ts.map +1 -1
  56. package/lib/runtime-state.js.map +1 -1
  57. package/lib/stats/pro-analysis.d.ts +3 -2
  58. package/lib/stats/pro-analysis.d.ts.map +1 -1
  59. package/lib/stats/pro-analysis.js +10 -9
  60. package/lib/stats/pro-analysis.js.map +1 -1
  61. package/lib/sync/run-sync.d.ts +2 -1
  62. package/lib/sync/run-sync.d.ts.map +1 -1
  63. package/lib/sync/run-sync.js +4 -3
  64. package/lib/sync/run-sync.js.map +1 -1
  65. package/lib/types.d.ts +2 -0
  66. package/lib/types.d.ts.map +1 -1
  67. package/lib/types.js.map +1 -1
  68. package/package.json +8 -8
  69. package/plugin.js +4 -0
  70. package/skills/lottery/tools/compute-recommend/index.js +1 -1
  71. package/skills/lottery/tools/compute-recommend/index.ts +1 -1
  72. package/skills/lottery/tools/history/index.js +2 -1
  73. package/skills/lottery/tools/history/index.ts +2 -1
  74. package/skills/lottery/tools/save-prediction/index.js +1 -1
  75. package/skills/lottery/tools/save-prediction/index.ts +1 -1
  76. package/skills/lottery/tools/stats-snapshot/index.js +1 -1
  77. package/skills/lottery/tools/stats-snapshot/index.ts +1 -1
  78. package/skills/lottery/tools/sync/index.js +1 -1
  79. package/skills/lottery/tools/sync/index.ts +1 -0
  80. package/src/command-helpers.ts +3 -0
  81. package/src/evaluate/backtest.ts +13 -11
  82. package/src/evaluate/tracker.ts +10 -8
  83. package/src/evaluate/train-weights.ts +13 -11
  84. package/src/games/kl8-groups.ts +4 -1
  85. package/src/i18n.ts +222 -0
  86. package/src/lottery-tool-handlers.ts +12 -7
  87. package/src/pipeline.ts +10 -7
  88. package/src/recommend/game-pick.ts +40 -28
  89. package/src/recommend/report.ts +18 -8
  90. package/src/runtime-state.ts +2 -0
  91. package/src/stats/pro-analysis.ts +11 -7
  92. package/src/sync/run-sync.ts +5 -2
  93. package/src/types.ts +2 -0
@@ -1,9 +1,11 @@
1
+ import type { Locale } from 'zhin.js/i18n';
1
2
  import { createToken } from 'zhin.js';
2
3
  import type { LotteryConfig } from './config.js';
3
4
  import type { LotteryDb } from './db.js';
4
5
  import type { GameId } from './types.js';
5
6
 
6
7
  export interface LotteryRuntime {
8
+ readonly locale?: Locale;
7
9
  readonly db: LotteryDb;
8
10
  readonly config: Readonly<LotteryConfig>;
9
11
  readonly enabledGames: readonly GameId[];
@@ -1,3 +1,5 @@
1
+ import type { Locale } from 'zhin.js/i18n';
2
+ import { messages as t } from '../i18n.js';
1
3
  import { DEFAULT_WEIGHTS, type DrawNumbers, type GameId, type NormalizedDraw, type ScoreWeights } from '../types.js';
2
4
 
3
5
  import { formatWeights, normalizeWeights } from './weights.js';
@@ -59,6 +61,7 @@ export function computeProMetrics(
59
61
  poolMin?: number,
60
62
  poolMax?: number,
61
63
  mid?: number,
64
+ locale?: Locale,
62
65
  ): import('../types.js').ProMetrics {
63
66
  const odd = pick.filter((n) => n % 2 === 1).length;
64
67
  const even = pick.length - odd;
@@ -76,7 +79,7 @@ export function computeProMetrics(
76
79
  const idx = Math.min(2, Math.floor((n - poolMin) / size));
77
80
  z[idx] = (z[idx] ?? 0) + 1;
78
81
  }
79
- zones = `三区 ${z.join(':')}`;
82
+ zones = t(locale, 'zones', { zones: z.join(':') });
80
83
  }
81
84
 
82
85
  const rows = draws.map((d) => extractFlat(d.numbers, gameId)).filter((a) => a.length);
@@ -90,13 +93,13 @@ export function computeProMetrics(
90
93
  .join(',');
91
94
 
92
95
  return {
93
- oddEven: `奇偶 ${odd}:${even}`,
94
- bigSmall: `大小 ${big}:${small}`,
96
+ oddEven: t(locale, 'oddEven', { odd, even }),
97
+ bigSmall: t(locale, 'bigSmall', { big, small }),
95
98
  sum,
96
99
  span,
97
100
  zones,
98
- recentHot: recentHot ? `近10期热号 ${recentHot}` : '',
99
- modelWeights: `权重 ${formatWeights(weights)}`,
101
+ recentHot: recentHot ? t(locale, 'recentHot', { numbers: recentHot }) : '',
102
+ modelWeights: t(locale, 'weights', { weights: formatWeights(weights) }),
100
103
  };
101
104
  }
102
105
 
@@ -104,6 +107,7 @@ export function computeDigitProMetrics(
104
107
  digits: number[],
105
108
  draws: NormalizedDraw[],
106
109
  weights: ScoreWeights,
110
+ locale?: Locale,
107
111
  ): import('../types.js').ProMetrics {
108
112
  const sum = digits.reduce((a, b) => a + b, 0);
109
113
  const span = digits.length ? Math.max(...digits) - Math.min(...digits) : 0;
@@ -115,7 +119,7 @@ export function computeDigitProMetrics(
115
119
  for (let d = 0; d <= 9; d++) freq.set(d, 0);
116
120
  col.slice(0, RECENT_WINDOW).forEach((n) => freq.set(n, (freq.get(n) ?? 0) + 1));
117
121
  const top = [...freq.entries()].sort((a, b) => b[1] - a[1]).slice(0, 3).map(([d]) => d);
118
- posHints.push(`第${pos + 1}位[${top.join(',')}]`);
122
+ posHints.push(t(locale, 'digitPos', { position: pos + 1, numbers: top.join(',') }));
119
123
  }
120
124
  return {
121
125
  oddEven: '',
@@ -124,7 +128,7 @@ export function computeDigitProMetrics(
124
128
  span,
125
129
  digitPos: posHints.join(' '),
126
130
  recentHot: '',
127
- modelWeights: `权重 ${formatWeights(weights)}`,
131
+ modelWeights: t(locale, 'weights', { weights: formatWeights(weights) }),
128
132
  };
129
133
  }
130
134
 
@@ -1,3 +1,5 @@
1
+ import type { Locale } from 'zhin.js/i18n';
2
+ import { messages as t } from '../i18n.js';
1
3
  import type { GameId, NormalizedDraw } from '../types.js';
2
4
  import { syncGame, type LotteryDb } from '../db.js';
3
5
 
@@ -6,9 +8,10 @@ export async function runDataSync(
6
8
  enabledGames: () => GameId[],
7
9
  historyLimit: number,
8
10
  gameId?: GameId,
11
+ locale?: Locale,
9
12
  ): Promise<{ text: string; newSummary: string; inserted: NormalizedDraw[] }> {
10
13
  const db = getDb();
11
- if (!db) return { text: 'db not ready', newSummary: '', inserted: [] };
14
+ if (!db) return { text: t(locale, 'dbNotReady'), newSummary: '', inserted: [] };
12
15
  const ids = gameId ? [gameId] : enabledGames();
13
16
  const parts: string[] = [];
14
17
  const newParts: string[] = [];
@@ -26,7 +29,7 @@ export async function runDataSync(
26
29
  }
27
30
  }
28
31
  return {
29
- text: `sync ${parts.join(', ')}`,
32
+ text: t(locale, 'syncResult', { result: parts.join(', ') }),
30
33
  newSummary: newParts.join('; '),
31
34
  inserted,
32
35
  };
package/src/types.ts CHANGED
@@ -54,6 +54,7 @@ export interface StatsSnapshot {
54
54
  }
55
55
 
56
56
  export interface GamePick {
57
+ locale?: import('zhin.js/i18n').Locale;
57
58
  gameId: GameId;
58
59
  label: string;
59
60
  numbers: DrawNumbers;
@@ -81,6 +82,7 @@ export interface HitSummary {
81
82
  }
82
83
 
83
84
  export interface DailyReport {
85
+ locale?: import('zhin.js/i18n').Locale;
84
86
  date: string;
85
87
  picks: GamePick[];
86
88
  disclaimer: string;