From fd1f82f2f5b576bad4e0ba3b6fc54a4cfd895496 Mon Sep 17 00:00:00 2001 From: koalasat Date: Thu, 18 Jul 2024 01:34:34 +0200 Subject: [PATCH 1/3] Fix telegram bot --- api/management/commands/telegram_watcher.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/api/management/commands/telegram_watcher.py b/api/management/commands/telegram_watcher.py index 44ce5c69..d626b756 100644 --- a/api/management/commands/telegram_watcher.py +++ b/api/management/commands/telegram_watcher.py @@ -50,16 +50,16 @@ class Command(BaseCommand): parts = message.split(" ") if len(parts) < 2: self.notifications.send_telegram_message( - chat_id=result["message"]["from"]["id"], - text='You must enable the notifications bot using the RoboSats client. Click on your "Robot robot" -> "Enable Telegram" and follow the link or scan the QR code.', + result["message"]["from"]["id"], + 'You must enable the notifications bot using the RoboSats client. Click on your "Robot robot" -> "Enable Telegram" and follow the link or scan the QR code.', ) continue token = parts[-1] robot = Robot.objects.filter(telegram_token=token).first() if not robot: self.notifications.send_telegram_message( - chat_id=result["message"]["from"]["id"], - text=f'Wops, invalid token! There is no Robot with telegram chat token "{token}"', + result["message"]["from"]["id"], + f'Wops, invalid token! There is no Robot with telegram chat token "{token}"', ) continue From fbfa7a060ba91edd5d0744c8dc27dbba72342cea Mon Sep 17 00:00:00 2001 From: koalasat Date: Thu, 18 Jul 2024 12:05:04 +0200 Subject: [PATCH 2/3] Fix telegram bot --- api/management/commands/telegram_watcher.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/api/management/commands/telegram_watcher.py b/api/management/commands/telegram_watcher.py index d626b756..bc570363 100644 --- a/api/management/commands/telegram_watcher.py +++ b/api/management/commands/telegram_watcher.py @@ -52,6 +52,7 @@ class Command(BaseCommand): self.notifications.send_telegram_message( result["message"]["from"]["id"], 'You must enable the notifications bot using the RoboSats client. Click on your "Robot robot" -> "Enable Telegram" and follow the link or scan the QR code.', + "", ) continue token = parts[-1] @@ -60,6 +61,7 @@ class Command(BaseCommand): self.notifications.send_telegram_message( result["message"]["from"]["id"], f'Wops, invalid token! There is no Robot with telegram chat token "{token}"', + "", ) continue From 70fc02b24243ed66d1223ed709aa9c2719ddfd21 Mon Sep 17 00:00:00 2001 From: koalasat Date: Thu, 18 Jul 2024 14:06:57 +0200 Subject: [PATCH 3/3] Fix telegram bot --- api/management/commands/telegram_watcher.py | 2 -- api/notifications.py | 4 ++-- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/api/management/commands/telegram_watcher.py b/api/management/commands/telegram_watcher.py index bc570363..d626b756 100644 --- a/api/management/commands/telegram_watcher.py +++ b/api/management/commands/telegram_watcher.py @@ -52,7 +52,6 @@ class Command(BaseCommand): self.notifications.send_telegram_message( result["message"]["from"]["id"], 'You must enable the notifications bot using the RoboSats client. Click on your "Robot robot" -> "Enable Telegram" and follow the link or scan the QR code.', - "", ) continue token = parts[-1] @@ -61,7 +60,6 @@ class Command(BaseCommand): self.notifications.send_telegram_message( result["message"]["from"]["id"], f'Wops, invalid token! There is no Robot with telegram chat token "{token}"', - "", ) continue diff --git a/api/notifications.py b/api/notifications.py index 7adc9f60..57ec4a42 100644 --- a/api/notifications.py +++ b/api/notifications.py @@ -37,13 +37,13 @@ class Notifications: if robot.telegram_enabled: self.send_telegram_message(robot.telegram_chat_id, title, description) - def save_message(self, order, robot, title, description): + def save_message(self, order, robot, title, description=""): """Save a message for a user""" Notification.objects.create( title=title, description=description, robot=robot, order=order ) - def send_telegram_message(self, chat_id, title, description): + def send_telegram_message(self, chat_id, title, description=""): """sends a message to a user with telegram notifications enabled""" bot_token = config("TELEGRAM_TOKEN")