Skip to content

Conversation

@JASON0916
Copy link
Contributor

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.

@leandrotoledo
Copy link
Member

Hey Jason, thanks for the pull request. I'll be testing/reviewing your code.
You mentioned about the Chinese firewall issue, how about a proxy feature? Would that help? If so, would you file a bug so we could start discussing more about it?

@leandrotoledo
Copy link
Member

Would you mind to push ignoring .idea folder though? Thanks!

@JASON0916
Copy link
Contributor Author

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.

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.

@leandrotoledo
Copy link
Member

No worries at all.
The way you simplified the code looks great! I made some comments and considerations. How about a is_inputfile function on InputFile to make the if even cleaner?

data['photo', 'video', ...] could be either:

  • a file instance, like open('telegram.png', 'rb') or
  • a str, like 'http://telegram.org/telegram.png (InputFile takes care to download and stream the content), as I'm writing this the HEAD tests if 'http' in data['video'], but I'm sure there are better ways to validate an URL.

if none of the options above, it falls on urlencode(data) simple post request.

Thanks!

@JASON0916
Copy link
Contributor Author

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?

@leandrotoledo
Copy link
Member

Uhm, after reading the post you sent, startswith seems to be enough for
now, we can handle URL errors when fetching content then.
Em 11/07/2015 2:31 AM, "CM" notifications@github.com escreveu:

I found the discussion related on discussion site
http://stackoverflow.com/questions/827557/how-do-you-validate-a-url-with-a-regular-expression-in-python.
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?


Reply to this email directly or view it on GitHub
#2 (comment)
.

@python-telegram-bot python-telegram-bot locked and limited conversation to collaborators Jul 11, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants