mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-31 18:41:36 +00:00
Merge branch 'RoboSats:main' into ui-updates
This commit is contained in:
commit
f4d4ebe46a
@ -50,16 +50,16 @@ class Command(BaseCommand):
|
|||||||
parts = message.split(" ")
|
parts = message.split(" ")
|
||||||
if len(parts) < 2:
|
if len(parts) < 2:
|
||||||
self.notifications.send_telegram_message(
|
self.notifications.send_telegram_message(
|
||||||
chat_id=result["message"]["from"]["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.',
|
'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
|
continue
|
||||||
token = parts[-1]
|
token = parts[-1]
|
||||||
robot = Robot.objects.filter(telegram_token=token).first()
|
robot = Robot.objects.filter(telegram_token=token).first()
|
||||||
if not robot:
|
if not robot:
|
||||||
self.notifications.send_telegram_message(
|
self.notifications.send_telegram_message(
|
||||||
chat_id=result["message"]["from"]["id"],
|
result["message"]["from"]["id"],
|
||||||
text=f'Wops, invalid token! There is no Robot with telegram chat token "{token}"',
|
f'Wops, invalid token! There is no Robot with telegram chat token "{token}"',
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
|
||||||
|
@ -37,13 +37,13 @@ class Notifications:
|
|||||||
if robot.telegram_enabled:
|
if robot.telegram_enabled:
|
||||||
self.send_telegram_message(robot.telegram_chat_id, title, description)
|
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"""
|
"""Save a message for a user"""
|
||||||
Notification.objects.create(
|
Notification.objects.create(
|
||||||
title=title, description=description, robot=robot, order=order
|
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"""
|
"""sends a message to a user with telegram notifications enabled"""
|
||||||
|
|
||||||
bot_token = config("TELEGRAM_TOKEN")
|
bot_token = config("TELEGRAM_TOKEN")
|
||||||
|
Loading…
Reference in New Issue
Block a user