Skip to content

Commit

Permalink
Fix incorrect parameter encoding in send_image and send_document methods
Browse files Browse the repository at this point in the history
  • Loading branch information
randhana committed Jun 26, 2024
1 parent 6cc28e3 commit 9ce7787
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions telebotpy/telebot.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ def send_image(self, image_filename, caption):
url = f"https://api.telegram.org/bot{self.token}/sendPhoto"
date_time = self._get_date_time()
files = {
'photo': (image_filename, image_file)
'photo': image_file
}
params = {
data = {
'chat_id': self.chat_id,
'caption': caption + " \n" + date_time
}

try:
response = requests.post(url, data=params, files=files)
response = requests.post(url, files=files, data=data)
self._handle_response(response)
except requests.exceptions.RequestException as e:
print(f"Failed to send image: {e}")
Expand All @@ -57,15 +57,15 @@ def send_document(self, document_path, caption):
url = f"https://api.telegram.org/bot{self.token}/sendDocument"
date_time = self._get_date_time()
files = {
'document': (document_path, document_file)
'document': document_file
}
params = {
data = {
'chat_id': self.chat_id,
'caption': caption + " \n" + date_time
}

try:
response = requests.post(url, data=params, files=files)
response = requests.post(url, files=files, data=data)
self._handle_response(response)
except requests.exceptions.RequestException as e:
print(f"Failed to send document: {e}")

0 comments on commit 9ce7787

Please sign in to comment.