fix: 修复 Telegram 推送消息对齐问题和自动生成账户名
- 修复 Telegram 订单成功/失败消息的左对齐问题,移除前导空格 - 在导入钱包时,如果未提供账户名,自动生成使用钱包地址后四位的名称 - 优化消息格式,确保在 Telegram 中正确显示
This commit is contained in:
@@ -111,7 +111,25 @@ class AccountService(
|
||||
val encryptedApiSecret = apiKeyCreds.secret?.let { cryptoUtils.encrypt(it) }
|
||||
val encryptedApiPassphrase = apiKeyCreds.passphrase?.let { cryptoUtils.encrypt(it) }
|
||||
|
||||
// 8. 创建账户
|
||||
// 8. 生成账户名称(如果未提供,使用钱包地址后四位)
|
||||
val accountName = if (request.accountName.isNullOrBlank()) {
|
||||
val walletAddress = request.walletAddress.trim()
|
||||
// 取地址后四位(去掉 0x 前缀后取后四位)
|
||||
val addressWithoutPrefix = if (walletAddress.startsWith("0x") || walletAddress.startsWith("0X")) {
|
||||
walletAddress.substring(2)
|
||||
} else {
|
||||
walletAddress
|
||||
}
|
||||
if (addressWithoutPrefix.length >= 4) {
|
||||
addressWithoutPrefix.substring(addressWithoutPrefix.length - 4).uppercase()
|
||||
} else {
|
||||
addressWithoutPrefix.uppercase()
|
||||
}
|
||||
} else {
|
||||
request.accountName.trim()
|
||||
}
|
||||
|
||||
// 9. 创建账户
|
||||
val account = Account(
|
||||
privateKey = encryptedPrivateKey, // 存储加密后的私钥
|
||||
walletAddress = request.walletAddress,
|
||||
@@ -119,7 +137,7 @@ class AccountService(
|
||||
apiKey = apiKeyCreds.apiKey,
|
||||
apiSecret = encryptedApiSecret, // 存储加密后的 API Secret
|
||||
apiPassphrase = encryptedApiPassphrase, // 存储加密后的 API Passphrase
|
||||
accountName = request.accountName,
|
||||
accountName = accountName,
|
||||
isDefault = false, // 不再支持默认账户
|
||||
isEnabled = request.isEnabled,
|
||||
createdAt = System.currentTimeMillis(),
|
||||
|
||||
+26
-30
@@ -479,20 +479,18 @@ class TelegramNotificationService(
|
||||
""
|
||||
}
|
||||
|
||||
return """
|
||||
✅ <b>$orderCreatedSuccess</b>
|
||||
|
||||
📊 <b>$orderInfo:</b>
|
||||
• $orderIdLabel: <code>${orderId ?: unknown}</code>
|
||||
• $marketLabel: $marketDisplay$outcomeDisplay
|
||||
• $sideLabel: <b>$sideDisplay</b>
|
||||
• $priceLabel: <code>$price</code>
|
||||
• $quantityLabel: <code>$size</code> shares
|
||||
• $amountLabel: <code>$amountDisplay</code> USDC
|
||||
• $accountLabel: $escapedAccountInfo
|
||||
|
||||
⏰ $timeLabel: <code>$time</code>
|
||||
""".trimIndent()
|
||||
return """✅ <b>$orderCreatedSuccess</b>
|
||||
|
||||
📊 <b>$orderInfo:</b>
|
||||
• $orderIdLabel: <code>${orderId ?: unknown}</code>
|
||||
• $marketLabel: $marketDisplay$outcomeDisplay
|
||||
• $sideLabel: <b>$sideDisplay</b>
|
||||
• $priceLabel: <code>$price</code>
|
||||
• $quantityLabel: <code>$size</code> shares
|
||||
• $amountLabel: <code>$amountDisplay</code> USDC
|
||||
• $accountLabel: $escapedAccountInfo
|
||||
|
||||
⏰ $timeLabel: <code>$time</code>"""
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -605,22 +603,20 @@ class TelegramNotificationService(
|
||||
""
|
||||
}
|
||||
|
||||
return """
|
||||
❌ <b>$orderCreatedFailed</b>
|
||||
|
||||
📊 <b>$orderInfo:</b>
|
||||
• $marketLabel: $marketDisplay$outcomeDisplay
|
||||
• $sideLabel: <b>$sideDisplay</b>
|
||||
• $priceLabel: <code>$price</code>
|
||||
• $quantityLabel: <code>$size</code> shares
|
||||
• $amountLabel: <code>$amountDisplay</code> USDC
|
||||
• $accountLabel: $escapedAccountInfo
|
||||
|
||||
⚠️ <b>$errorInfo:</b>
|
||||
<code>$escapedErrorMessage</code>
|
||||
|
||||
⏰ $timeLabel: <code>$time</code>
|
||||
""".trimIndent()
|
||||
return """❌ <b>$orderCreatedFailed</b>
|
||||
|
||||
📊 <b>$orderInfo:</b>
|
||||
• $marketLabel: $marketDisplay$outcomeDisplay
|
||||
• $sideLabel: <b>$sideDisplay</b>
|
||||
• $priceLabel: <code>$price</code>
|
||||
• $quantityLabel: <code>$size</code> shares
|
||||
• $amountLabel: <code>$amountDisplay</code> USDC
|
||||
• $accountLabel: $escapedAccountInfo
|
||||
|
||||
⚠️ <b>$errorInfo:</b>
|
||||
<code>$escapedErrorMessage</code>
|
||||
|
||||
⏰ $timeLabel: <code>$time</code>"""
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user