-
Notifications
You must be signed in to change notification settings - Fork 6k
No empty strings in to_dict #494
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
232a0b0
651119f
38f2064
4dee785
27b2fd6
e69e99c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,13 +40,14 @@ class File(TelegramObject): | |
|
|
||
| """ | ||
|
|
||
| def __init__(self, file_id, bot, file_size=0, file_path='', **kwargs): | ||
| def __init__(self, file_id, bot, file_size=None, file_path=None, **kwargs): | ||
| # Required | ||
| self.file_id = str(file_id) | ||
|
|
||
| # Optionals | ||
| self.file_size = int(file_size) | ||
| self.file_path = str(file_path) | ||
| self.file_size = file_size | ||
| if file_path: | ||
| self.file_path = str(file_path) | ||
|
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. Just do
Member
Author
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. Right, whoops. I removed the other ones. Seems like I missed these. |
||
|
|
||
| self.bot = bot | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,7 +44,14 @@ class User(TelegramObject): | |
| bot (Optional[Bot]): The Bot to use for instance methods | ||
| """ | ||
|
|
||
| def __init__(self, id, first_name, type='', last_name='', username='', bot=None, **kwargs): | ||
| def __init__(self, | ||
| id, | ||
| first_name, | ||
| type=None, | ||
|
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. I don't see the
Member
Author
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. Hmm.. I don't think it's ever been there tbh.. I might be us who made an error and confused User for Chat or something.
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. I think Telegram removed it.
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. I think I remember it from the official docs as well, but I could be wrong... |
||
| last_name=None, | ||
| username=None, | ||
| bot=None, | ||
| **kwargs): | ||
| # Required | ||
| self.id = int(id) | ||
| self.first_name = first_name | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -40,13 +40,20 @@ class WebhookInfo(TelegramObject): | |
|
|
||
| """ | ||
|
|
||
| def __init__(self, url, has_custom_certificate, pending_update_count, **kwargs): | ||
| def __init__(self, | ||
| url, | ||
| has_custom_certificate, | ||
| pending_update_count, | ||
| last_error_date=None, | ||
| last_error_message=None, | ||
|
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. We're missing optionals:
Member
Author
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.
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. I thought that too, so I checked the official December 4th release notes and it wasn't there, so lets fix it here while we're at it.
Member
Author
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. |
||
| **kwargs): | ||
| # Required | ||
| self.url = url | ||
| self.has_custom_certificate = has_custom_certificate | ||
| self.pending_update_count = pending_update_count | ||
| self.last_error_date = kwargs.get('last_error_date', '') | ||
| self.last_error_message = kwargs.get('last_error_message', '') | ||
| # Optional | ||
| self.last_error_date = last_error_date | ||
| self.last_error_message = last_error_message | ||
|
|
||
| @staticmethod | ||
| def de_json(data, bot): | ||
|
|
||
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.
The API of Chat calls this var as
all_members_are_administrators, here we useadmins. Is there anything that translatesadmins. I think we actually have a bug here, or telegram might have silently changed the API.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.
I'm about 90% sure they changed their API... so should we change it, or like keep both, or?
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.
We should follow their official API.
We can do bkwd-compat for a while using **kwargs.
@jh0ker What do you think?
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.
I'd say we keep bkwd-compat