-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
Conversation
Hey Jason, thanks for the pull request. I'll be testing/reviewing your code. |
Would you mind to push ignoring .idea folder though? Thanks! |
Actually i am going to buy a VPN latter. I noticed that there is a new version of your code, i will work on the new version then, just ignore the pull request this time 0 -0. I'm sorry for the .idea, i will pay attention on that next time. |
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): |
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.
In case of data is None, data.keys() will raise an AttributeError.
No worries at all. data['photo', 'video', ...] could be either:
if none of the options above, it falls on urlencode(data) simple post request. Thanks! |
I found the discussion related on discussion site. I think we may use urlparse in our case, even url.startwith('http') is OK for the flexible url rules. There seems to be little invalid url. How do you think about that? |
Uhm, after reading the post you sent, startswith seems to be enough for
|
The change is mainly about Bot._requestUrl(self, url, method, data=None). In sendPhoto(), sendAudio() and sendVideo i found that data.keys()[1] represents the file type, so i tried to simply the code.
For Chinese government's sake i can't access telegram, which disables my test. I'm sorry if my code brings you trouble.