dashboard: userlarga message yozish uchun api qoshildi
This commit is contained in:
@@ -30,4 +30,21 @@ def send_to_telegram(chat_id, order_id):
|
||||
|
||||
except Exception as e:
|
||||
print(f"Telegram xatolik: {e}")
|
||||
return False
|
||||
|
||||
|
||||
def send_message(chat_id, message):
|
||||
bot_token = settings.BOT_TOKEN
|
||||
|
||||
try:
|
||||
url = f"https://api.telegram.org/bot{bot_token}/sendMessage"
|
||||
data = {
|
||||
"chat_id": chat_id,
|
||||
"text": message
|
||||
}
|
||||
response = requests.post(url, data=data)
|
||||
print(response.json())
|
||||
return True
|
||||
except Exception as e:
|
||||
print(f"Telegram xatosi: {e}")
|
||||
return False
|
||||
Reference in New Issue
Block a user