-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Simplify code #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -561,36 +561,16 @@ def _requestUrl(self, | |
| """ | ||
|
|
||
| if method == 'POST': | ||
| if 'photo' in data and isinstance(data['photo'], file): | ||
| file_types = ['photo', 'audio', 'document'] | ||
| # 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): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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)) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing 'video'