Skip to content
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

Bot API 6.8: Stories, voting as a chat, and other minor changes #2030

Merged
merged 6 commits into from
Aug 20, 2023

Conversation

coder2020official
Copy link
Collaborator

@coder2020official coder2020official commented Aug 18, 2023

August 18, 2023

Bot API 6.8

  • Added the field story to the class Message for messages with forwarded stories. Currently, it holds no information.

  • Added the field voter_chat to the class PollAnswer, to contain channel chat voters in Polls. For backward compatibility, the field user in such objects will contain the user 136817688 (@Channel_Bot).

  • Added the field emoji_status_expiration_date to the class Chat.

  • Added the method unpinAllGeneralForumTopicMessages.

  • Increased to 512 characters the maximum length of the startapp parameter in direct Web App links(NOT NEEDED)

@coder2020official
Copy link
Collaborator Author

@Badiboy can you clarify one thing: what is the purpose of to_dict in types.PollAnswer? Check previous commit where I added voter_chat, and if to_dict is necessary I have to add to_dict for types.Chat. I have checked api doc and I see no need for to_dict for PollAnswer, since it is an update. Or did I miss something?

@coder2020official
Copy link
Collaborator Author

I guess I am done except for the PollAnswer issue I described above.

@Badiboy
Copy link
Collaborator

Badiboy commented Aug 18, 2023

@Badiboy can you clarify one thing: what is the purpose of to_dict in types.PollAnswer?

It was long long time ago. :)
#839

They are not needed in library. And I suppose they are not used by anybody.
I prefer them to stay as far as they are already exists, but if you hardly want to remove it - I think they can be removed.

@Badiboy
Copy link
Collaborator

Badiboy commented Aug 18, 2023

The same you can check user.to_dict/to_json if you want to, I do not remember what's with these methods usage.

telebot/types.py Outdated

@classmethod
def de_json(cls, json_string):
return cls()
Copy link
Collaborator

Choose a reason for hiding this comment

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

image

Generally we proceed json in this way. Currently it does not matter, but I suppose it's better to have standart code signature even here.

telebot/types.py Outdated
for key in options:
setattr(self, key, options[key])
self.json = json_string

@property
def is_forwarded_story(self):
Copy link
Collaborator

Choose a reason for hiding this comment

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

See no reason in appearance of this property... No is_anumation, is_video, is_xxx - why now is_story?

@@ -6710,12 +6713,16 @@ def de_json(cls, json_string):
if (json_string is None): return None
obj = cls.check_json(json_string)
obj['user'] = User.de_json(obj['user'])
if 'voter_chat' in obj:
Copy link
Collaborator

Choose a reason for hiding this comment

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

User is now optional and should be processed the same as voter_chat with if

telebot/types.py Outdated
return cls(**obj)

def __init__(self, poll_id, user, option_ids, **kwargs):
def __init__(self, poll_id, user, option_ids, voter_chat=None, **kwargs):
Copy link
Collaborator

Choose a reason for hiding this comment

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

And user is optional here also... Seems we need to change init signature.

telebot/types.py Outdated
return cls(**obj)

def __init__(self, poll_id, user, option_ids, **kwargs):
def __init__(self, poll_id, user, option_ids, voter_chat=None, **kwargs):
self.poll_id: str = poll_id
self.user: User = user
Copy link
Collaborator

Choose a reason for hiding this comment

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

And here...

@Badiboy
Copy link
Collaborator

Badiboy commented Aug 18, 2023

@coder2020official I submitted review. If you don't see it let me know, means I did something wrong again )

@coder2020official coder2020official changed the title Update README.md Bot API 6.8: Stories, voting as a chat, and other minor changes Aug 19, 2023
@coder2020official
Copy link
Collaborator Author

@Badiboy i guess I am done, I removed the is_forwarded_story option(found it useless after ur comment), made user optional, improved new story class to check for json. Check the previous commit for more

@coder2020official
Copy link
Collaborator Author

Tip: You can also suggest a commit and I will be able to commit it right away
image

@Badiboy Badiboy merged commit 01b0071 into eternnoir:master Aug 20, 2023
8 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants