Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .idea/.name

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/encodings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions .idea/misc.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/modules.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions .idea/python-telegram-bot.iml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions .idea/scopes/scope_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 6 additions & 0 deletions .idea/vcs.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

605 changes: 605 additions & 0 deletions .idea/workspace.xml

Large diffs are not rendered by default.

30 changes: 5 additions & 25 deletions telegram/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -561,36 +561,16 @@ def _requestUrl(self,
"""

if method == 'POST':
if 'photo' in data and isinstance(data['photo'], file):
file_types = ['photo', 'audio', 'document']
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing 'video'

# In sendVideo(), sendAudio() and sendPhoto(), data.keys()[1] represents the file type
if data.keys()[1] in file_types and isinstance(data.items()[1], file):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In case of data is None, data.keys() will raise an AttributeError.

try:
photo = data.pop('photo')
file_pop = data.pop(data.keys()[1])

return requests.post(
url,
data=data,
files={'photo': photo}
)
except requests.RequestException as e:
raise TelegramError(str(e))
if 'audio' in data and isinstance(data['audio'], file):
try:
audio = data.pop('audio')

return requests.post(
url,
data=data,
files={'audio': audio}
)
except requests.RequestException as e:
raise TelegramError(str(e))
if 'document' in data and isinstance(data['document'], file):
try:
document = data.pop('document')

return requests.post(
url,
data=data,
files={'document': document}
files={data.keys()[1]: file_pop}
)
except requests.RequestException as e:
raise TelegramError(str(e))
Expand Down
2 changes: 1 addition & 1 deletion telegram_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@

if __name__ == '__main__':
testsuite = unittest.TestLoader().discover('.')
unittest.TextTestRunner(verbosity=1).run(testsuite)
unittest.TextTestRunner(verbosity=15).run(testsuite)