mirror of
https://github.com/discountry/ritmex-bot.git
synced 2026-09-11 17:28:08 +00:00
Compare commits
3
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
445e634aa1 | ||
|
|
4bb1fee995 | ||
|
|
aad14395e0 |
@@ -21,6 +21,8 @@ const TYPE_EMOJI: Record<string, string> = {
|
||||
custom: "📢",
|
||||
};
|
||||
|
||||
const LOG_PREFIX = "[Telegram]";
|
||||
|
||||
function formatNotificationMessage(notification: TradeNotification, accountLabel?: string): string {
|
||||
const levelEmoji = LEVEL_EMOJI[notification.level] ?? "";
|
||||
const typeEmoji = TYPE_EMOJI[notification.type] ?? "";
|
||||
@@ -94,12 +96,14 @@ export class TelegramNotifier implements NotificationSender {
|
||||
}),
|
||||
});
|
||||
|
||||
if (!response.ok) {
|
||||
const errorText = await response.text().catch(() => "unknown error");
|
||||
console.error(`[Telegram] Failed to send notification: ${response.status} ${errorText}`);
|
||||
if (response.ok) {
|
||||
console.info(`${LOG_PREFIX} Notification sent (status ${response.status}).`);
|
||||
return;
|
||||
}
|
||||
const errorText = await response.text().catch(() => "unknown error");
|
||||
console.error(`${LOG_PREFIX} Failed to send notification: ${response.status} ${errorText}`);
|
||||
} catch (error) {
|
||||
console.error(`[Telegram] Failed to send notification: ${error instanceof Error ? error.message : String(error)}`);
|
||||
console.error(`${LOG_PREFIX} Failed to send notification: ${error instanceof Error ? error.message : String(error)}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -645,7 +645,7 @@ export class MakerPointsEngine {
|
||||
"stop",
|
||||
`触发止损: 未实现亏损 ${position.unrealizedProfit.toFixed(4)} USDT`
|
||||
);
|
||||
this.notifier.send({
|
||||
this.notify({
|
||||
type: "stop_loss",
|
||||
level: "error",
|
||||
symbol: this.config.symbol,
|
||||
@@ -802,6 +802,10 @@ export class MakerPointsEngine {
|
||||
return getMidOrLast(this.depthSnapshot, this.tickerSnapshot);
|
||||
}
|
||||
|
||||
private notify(notification: TradeNotification): void {
|
||||
this.notifier.send(notification);
|
||||
}
|
||||
|
||||
private logReadinessBlockers(): void {
|
||||
if (!this.feedStatus.account && !this.readinessLogged.account) {
|
||||
this.tradeLog.push("info", t("log.maker.waitAccount"));
|
||||
@@ -887,7 +891,7 @@ export class MakerPointsEngine {
|
||||
const reference = this.getReferencePrice() ?? 0;
|
||||
|
||||
if (prevSide === "FLAT" && currentSide !== "FLAT") {
|
||||
this.notifier.send({
|
||||
this.notify({
|
||||
type: "position_opened",
|
||||
level: "info",
|
||||
symbol: this.config.symbol,
|
||||
@@ -902,7 +906,7 @@ export class MakerPointsEngine {
|
||||
} else if (currentSide === "FLAT" && prevSide !== "FLAT") {
|
||||
const pnl = position.unrealizedProfit;
|
||||
const closeType = this.tokenExpiredCloseOnlyMode ? "Token过期平仓" : "平仓";
|
||||
this.notifier.send({
|
||||
this.notify({
|
||||
type: "position_closed",
|
||||
level: "success",
|
||||
symbol: this.config.symbol,
|
||||
@@ -917,7 +921,7 @@ export class MakerPointsEngine {
|
||||
} else if (currentSide === prevSide && absChange > EPS) {
|
||||
const isIncrease = Math.abs(currentAmt) > Math.abs(prevAmt);
|
||||
if (isIncrease) {
|
||||
this.notifier.send({
|
||||
this.notify({
|
||||
type: "order_filled",
|
||||
level: "info",
|
||||
symbol: this.config.symbol,
|
||||
@@ -930,7 +934,7 @@ export class MakerPointsEngine {
|
||||
},
|
||||
});
|
||||
} else {
|
||||
this.notifier.send({
|
||||
this.notify({
|
||||
type: "order_filled",
|
||||
level: "info",
|
||||
symbol: this.config.symbol,
|
||||
@@ -944,7 +948,7 @@ export class MakerPointsEngine {
|
||||
});
|
||||
}
|
||||
} else if (currentSide !== prevSide && currentSide !== "FLAT" && prevSide !== "FLAT") {
|
||||
this.notifier.send({
|
||||
this.notify({
|
||||
type: "position_opened",
|
||||
level: "info",
|
||||
symbol: this.config.symbol,
|
||||
@@ -995,7 +999,7 @@ export class MakerPointsEngine {
|
||||
}
|
||||
|
||||
if (!this.tokenExpiryNotified) {
|
||||
this.notifier.send({
|
||||
this.notify({
|
||||
type: "token_expired",
|
||||
level: "warn",
|
||||
symbol: this.config.symbol,
|
||||
|
||||
Reference in New Issue
Block a user