Update async_tgvoicebot.py
Browse files- async_tgvoicebot.py +2 -2
async_tgvoicebot.py
CHANGED
|
@@ -7,7 +7,7 @@ from async_ai_voice import send_to_voice_AI # Imports the send_to_voice_AI func
|
|
| 7 |
|
| 8 |
# Telegram Bot API setup
|
| 9 |
TELEGRAM_BOT_TOKEN = os.getenv('TELEGRAM_BOT_TOKEN') # Retrieves the Telegram bot token from environment variables
|
| 10 |
-
TELEGRAM_API_URL = f"https://
|
| 11 |
|
| 12 |
async def get_voice_file(session, file_id):
|
| 13 |
"""
|
|
@@ -20,7 +20,7 @@ async def get_voice_file(session, file_id):
|
|
| 20 |
file_path = file_info['result']['file_path'] # Extracts the file path from the response
|
| 21 |
|
| 22 |
# Download file
|
| 23 |
-
file_url = f"https://
|
| 24 |
async with session.get(file_url) as response: # Asynchronously sends a GET request to download the file
|
| 25 |
return await response.read() # Awaits and returns the raw bytes of the downloaded file
|
| 26 |
|
|
|
|
| 7 |
|
| 8 |
# Telegram Bot API setup
|
| 9 |
TELEGRAM_BOT_TOKEN = os.getenv('TELEGRAM_BOT_TOKEN') # Retrieves the Telegram bot token from environment variables
|
| 10 |
+
TELEGRAM_API_URL = f"https://api.telegram.org/bot{TELEGRAM_BOT_TOKEN}" # Constructs the base Telegram API URL using the bot token
|
| 11 |
|
| 12 |
async def get_voice_file(session, file_id):
|
| 13 |
"""
|
|
|
|
| 20 |
file_path = file_info['result']['file_path'] # Extracts the file path from the response
|
| 21 |
|
| 22 |
# Download file
|
| 23 |
+
file_url = f"https://api.telegram.org/file/bot{TELEGRAM_BOT_TOKEN}/{file_path}" # Constructs the URL to download the actual voice file
|
| 24 |
async with session.get(file_url) as response: # Asynchronously sends a GET request to download the file
|
| 25 |
return await response.read() # Awaits and returns the raw bytes of the downloaded file
|
| 26 |
|