baha-99 commited on
Commit
c7582b3
·
verified ·
1 Parent(s): 24697df

Update bot_telegram.py

Browse files
Files changed (1) hide show
  1. bot_telegram.py +7 -13
bot_telegram.py CHANGED
@@ -193,7 +193,7 @@ class TelegramBot:
193
 
194
  headers = {
195
  "Authorization": f"Bearer {self.auth_token}",
196
- "accept": "application/json"
197
  }
198
 
199
  async with aiohttp.ClientSession() as session:
@@ -207,20 +207,14 @@ class TelegramBot:
207
  # Send file to API
208
  async with session.post(self.excel_url, headers=headers, data=form_data) as response:
209
  if response.status == 200:
210
- response_json = await response.json()
211
- file_content = response_json.get('file_content')
212
- filename = response_json.get('filename', 'rfp_responses.xlsx')
213
-
214
- if not file_content:
215
- await processing_msg.edit_text("❌ Error: No file content received from server")
216
- return
217
-
218
- # Convert base64 string to bytes and send back to Telegram
219
- file_bytes = bytes(file_content)
220
  await context.bot.send_document(
221
  chat_id=update.effective_chat.id,
222
- document=io.BytesIO(file_bytes),
223
- filename=filename,
224
  caption="✅ Here's your processed Excel file with answers!"
225
  )
226
  await processing_msg.delete()
 
193
 
194
  headers = {
195
  "Authorization": f"Bearer {self.auth_token}",
196
+ "accept": "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
197
  }
198
 
199
  async with aiohttp.ClientSession() as session:
 
207
  # Send file to API
208
  async with session.post(self.excel_url, headers=headers, data=form_data) as response:
209
  if response.status == 200:
210
+ # Get the Excel file content directly
211
+ file_content = await response.read()
212
+
213
+ # Send the Excel file back to Telegram
 
 
 
 
 
 
214
  await context.bot.send_document(
215
  chat_id=update.effective_chat.id,
216
+ document=io.BytesIO(file_content),
217
+ filename='rfp_responses.xlsx',
218
  caption="✅ Here's your processed Excel file with answers!"
219
  )
220
  await processing_msg.delete()