From 03280ecb36b3e0b2c21ea2b36c798f4fd9c1d0ce Mon Sep 17 00:00:00 2001 From: Daniel Chew Date: Thu, 16 May 2024 20:59:33 +0800 Subject: [PATCH] fix --- pyth_observer/event.py | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/pyth_observer/event.py b/pyth_observer/event.py index 2389145..2e93539 100644 --- a/pyth_observer/event.py +++ b/pyth_observer/event.py @@ -129,15 +129,13 @@ async def send(self): f"https://api.telegram.org/bot{self.telegram_bot_token}/sendMessage" ) - formatted_message = ( - f"*Message:* {text['msg']}\n" - f"*Type:* {text['type']}\n" - f"*Publisher:* {text['publisher']}\n" - f"*Symbol:* {text['symbol']}\n" - f"*Publisher Price:* {text['publisher_price']}\n" - f"*Aggregate Price:* {text['aggregate_price']}\n" - f"*Deviation:* {text['deviation']:.2f}%" - ) + formatted_message = "" + for key, value in text.items(): + value_str = f"{value:.2f}%" if key == "deviation" else f"{value}" + formatted_message += ( + f"*{key.capitalize().replace('_', ' ')}:* {value_str}\n" + ) + message_data = { "chat_id": chat_id, "text": formatted_message,