From b9b71dc8428bd2a2fc77a9662a3c24afff61e6ef Mon Sep 17 00:00:00 2001 From: Reckless_Satoshi Date: Mon, 21 Feb 2022 18:12:42 -0800 Subject: [PATCH] Fixes for telegra messaing errors in production --- api/logics.py | 4 ++-- api/management/commands/telegram_watcher.py | 4 ++-- api/messages.py | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/api/logics.py b/api/logics.py index 265924f2..d6eb770f 100644 --- a/api/logics.py +++ b/api/logics.py @@ -30,7 +30,7 @@ FIAT_EXCHANGE_DURATION = int(config("FIAT_EXCHANGE_DURATION")) class Logics: - + telegram = Telegram() @classmethod def validate_already_maker_or_taker(cls, user): """Validates if a use is already not part of an active order""" @@ -129,7 +129,7 @@ class Logics: order.expires_at = timezone.now() + timedelta( seconds=Order.t_to_expire[Order.Status.TAK]) order.save() - Telegram.order_taken(order) + cls.telegram.order_taken(order) return True, None def is_buyer(order, user): diff --git a/api/management/commands/telegram_watcher.py b/api/management/commands/telegram_watcher.py index 5b06e700..e415dde2 100644 --- a/api/management/commands/telegram_watcher.py +++ b/api/management/commands/telegram_watcher.py @@ -16,7 +16,7 @@ class Command(BaseCommand): updates_url = f'https://api.telegram.org/bot{bot_token}/getUpdates' session = get_tor_session() - + telegram = Telegram() def handle(self, *args, **options): """Infinite loop to check for telegram updates. If it finds a new user (/start), enables it's taker found @@ -42,7 +42,7 @@ class Command(BaseCommand): continue profile.telegram_chat_id = result['message']['from']['id'] profile.telegram_lang_code = result['message']['from']['language_code'] - Telegram.welcome(profile.user) + self.telegram.welcome(profile.user) profile.telegram_enabled = True profile.save() diff --git a/api/messages.py b/api/messages.py index eec79f28..c968d678 100644 --- a/api/messages.py +++ b/api/messages.py @@ -46,7 +46,7 @@ class Telegram(): text = f'Hola ⚡{user.username}⚡, Te enviaré un mensaje cuando tu orden con ID {str(order.id)} haya sido tomada.' else: text = f"Hey ⚡{user.username}⚡, I will send you a message when someone takes your order with ID {str(order.id)}." - self.send_message(user=user, text=text) + self.send_message(user, text) return @@ -63,5 +63,5 @@ class Telegram(): else: text = f'Your order with ID {order.id} was taken by {taker_nick}!🥳 Visit http://{site}/order/{order.id} to proceed with the trade.' - self.send_message(user=user, text=text) + self.send_message(user, text) return \ No newline at end of file