@tgbotpress/plugin-energy 0.0.0-stage → 0.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.
package/README.md CHANGED
@@ -1,3 +1,3 @@
1
- # Temporary Holding Version
1
+ # @tgbotpress/plugin-energy
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ Energy management plugin package. The current pure entries are `./units` for decimal energy amounts and `./poll` for wallet polling lower-bound timestamps. Platform APIs, encrypted credentials, Tron polling, order workers and Telegram notifications remain host-owned until their transaction and key-management contracts are migrated.
package/package.json CHANGED
@@ -1,6 +1,42 @@
1
1
  {
2
2
  "name": "@tgbotpress/plugin-energy",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "publishConfig": {
6
+ "registry": "https://registry.npmjs.org"
7
+ },
8
+ "exports": {
9
+ ".": {
10
+ "types": "./src/index.d.ts",
11
+ "import": "./src/index.js"
12
+ },
13
+ "./units": {
14
+ "types": "./src/units.d.ts",
15
+ "import": "./src/units.js"
16
+ },
17
+ "./poll": {
18
+ "types": "./src/poll.d.ts",
19
+ "import": "./src/poll.js"
20
+ },
21
+ "./units.js": {
22
+ "types": "./src/units.d.ts",
23
+ "import": "./src/units.js"
24
+ },
25
+ "./poll.js": {
26
+ "types": "./src/poll.d.ts",
27
+ "import": "./src/poll.js"
28
+ }
29
+ },
30
+ "files": [
31
+ "src"
32
+ ],
33
+ "engines": {
34
+ "node": ">=22"
35
+ },
36
+ "peerDependencies": {
37
+ "@tgbotpress/plugin-sdk": "^0.1.0"
38
+ },
39
+ "devDependencies": {
40
+ "@tgbotpress/plugin-sdk": "file:../plugin-sdk"
41
+ }
42
+ }
package/src/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ import type { PluginManifest, TgbotpressPlugin } from '@tgbotpress/plugin-sdk'
2
+ export declare const manifest: PluginManifest
3
+ export declare const plugin: TgbotpressPlugin
package/src/index.js ADDED
@@ -0,0 +1,15 @@
1
+ export const manifest = {
2
+ id: 'energy',
3
+ version: '0.1.0',
4
+ hostRange: '>=1.0.0 <2.0.0',
5
+ sdkVersion: '0.1.0',
6
+ name: '能量管理',
7
+ description: '能量平台、订单和发放',
8
+ dependencies: [],
9
+ menuRoutes: ['admin.energy.platform.index','admin.energy.platformbot.index','admin.energy.package.index','admin.energy.order.index','admin.energy.quick.index','admin.energy.trade.index','admin.energy.aitrusteeship.index','admin.energy.aibishu.index','admin.energy.bindasendn.config'],
10
+ apiRoutes: ['/api/energy-platforms','/api/energy-platform-bots','/api/energy-packages','/api/energy-orders','/api/energy-quick-orders','/api/energy-trades','/api/energy-ai-trusteeship','/api/energy-ai-bishu','/api/bindasendn'],
11
+ tasks: ['energywalletinlisttrxusdt','monitorenergywallettrade','monitorenergywallettradelost','bishuwalletstop','getaitrusteeshipwalletresource','getaienergywalletresource','energyOrder','energyQuickOrder','handleaienergyorder','handleaienergybishu','recoveryenergy','getenergyplatformbalance','autoactivatebishu','handleenergyspecial','bindasendnusdt','sendenergytgmessage'],
12
+ drainTasks: ['energyOrder','energyQuickOrder','handleaienergyorder','handleaienergybishu','recoveryenergy','sendenergytgmessage'],
13
+ configTypes: ['command','keyreply','keyreply_keyboard'],
14
+ }
15
+ export const plugin = { manifest }
package/src/poll.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function energyWalletStartTimestamp(latest: string | null, saved: Date | string | null): string
package/src/poll.js ADDED
@@ -0,0 +1,9 @@
1
+ export function energyWalletStartTimestamp(latest, saved) {
2
+ let result = latest && /^\d{1,16}$/.test(latest) ? BigInt(latest) : 0n
3
+ if (saved) {
4
+ const raw = saved instanceof Date ? saved.toISOString() : String(saved)
5
+ const date = new Date(raw.includes('T') ? raw : raw.replace(' ', 'T') + '+08:00')
6
+ if (Number.isFinite(date.getTime())) { const threshold = BigInt(Math.max(0, date.getTime() - 10)); if (threshold > result) result = threshold }
7
+ }
8
+ return result.toString()
9
+ }
package/src/units.d.ts ADDED
@@ -0,0 +1 @@
1
+ export declare function decimalUnits(value: string, decimals?: number): string
package/src/units.js ADDED
@@ -0,0 +1,5 @@
1
+ export function decimalUnits(value, decimals = 6) {
2
+ const scale = 10n ** BigInt(decimals), whole = (BigInt(value) / scale).toString()
3
+ const fraction = (BigInt(value) % scale).toString().padStart(decimals, '0').replace(/0+$/, '')
4
+ return fraction ? whole + '.' + fraction : whole
5
+ }