mirror of
https://github.com/RoboSats/robosats.git
synced 2025-01-18 12:11:35 +00:00
Fix non enabled telegram order taken
This commit is contained in:
parent
d146f522f3
commit
3906ed73aa
@ -7,8 +7,6 @@ from api.models import Order, LNPayment, MarketTick, User, Currency
|
||||
from api.messages import Telegram
|
||||
from decouple import config
|
||||
|
||||
from api.tasks import follow_send_payment
|
||||
|
||||
import math
|
||||
import ast
|
||||
|
||||
|
@ -1,11 +1,13 @@
|
||||
from decouple import config
|
||||
from secrets import token_urlsafe
|
||||
from api.models import Order
|
||||
import requests
|
||||
from api.utils import get_tor_session
|
||||
|
||||
class Telegram():
|
||||
''' Simple telegram messages by requesting to API'''
|
||||
|
||||
session = get_tor_session()
|
||||
|
||||
def get_context(user):
|
||||
"""returns context needed to enable TG notifications"""
|
||||
context = {}
|
||||
@ -23,7 +25,7 @@ class Telegram():
|
||||
|
||||
return context
|
||||
|
||||
def send_message(user, text):
|
||||
def send_message(self, user, text):
|
||||
""" sends a message to a user with telegram notifications enabled"""
|
||||
|
||||
bot_token=config('TELEGRAM_TOKEN')
|
||||
@ -31,7 +33,7 @@ class Telegram():
|
||||
chat_id = user.profile.telegram_chat_id
|
||||
message_url = f'https://api.telegram.org/bot{bot_token}/sendMessage?chat_id={chat_id}&text={text}'
|
||||
|
||||
response = requests.get(message_url).json()
|
||||
response = self.session.get(message_url).json()
|
||||
print(response)
|
||||
|
||||
return
|
||||
@ -51,6 +53,9 @@ class Telegram():
|
||||
@classmethod
|
||||
def order_taken(cls, order):
|
||||
user = order.maker
|
||||
if not user.profile.telegram_enabled:
|
||||
return
|
||||
|
||||
lang = user.profile.telegram_lang_code
|
||||
taker_nick = order.taker.username
|
||||
site = config('HOST_NAME')
|
||||
|
Loading…
Reference in New Issue
Block a user