Skip to content

Commit

Permalink
Merge pull request eternnoir#1358 from Badiboy/master
Browse files Browse the repository at this point in the history
Update readme and typo
  • Loading branch information
Badiboy authored Nov 8, 2021
2 parents c39b3aa + e22a7fe commit 4ba2356
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

<p align="center">A simple, but extensible Python implementation for the <a href="https://core.telegram.org/bots/api">Telegram Bot API</a>.

## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#june-25-2021">5.3</a>!
## <p align="center">Supported Bot API version: <a href="https://core.telegram.org/bots/api#november-5-2021">5.4</a>!

## Contents

Expand Down Expand Up @@ -683,6 +683,7 @@ Result will be:

## API conformance

*[Bot API 5.4](https://core.telegram.org/bots/api#november-5-2021)
*[Bot API 5.3](https://core.telegram.org/bots/api#june-25-2021) - ChatMemberXXX classes are full copies of ChatMember
*[Bot API 5.2](https://core.telegram.org/bots/api#april-26-2021)
*[Bot API 5.1](https://core.telegram.org/bots/api#march-9-2021)
Expand Down
15 changes: 9 additions & 6 deletions telebot/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,6 @@ def enable_saving_states(self, filename="./.state-save/states.pkl"):
Enable saving states (by default saving disabled)
:param filename: Filename of saving file
"""

self.current_states = StateFile(filename=filename)
Expand Down Expand Up @@ -1690,30 +1689,34 @@ def create_chat_invite_link(
:param chat_id: Id: Unique identifier for the target chat or username of the target channel
(in the format @channelusername)
:param name: Invite link name; 0-32 characters
:param expire_date: Point in time (Unix timestamp) when the link will expire
:param member_limit: Maximum number of users that can be members of the chat simultaneously
:param creates_join_request: True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified
:return:
"""
return types.ChatInviteLink.de_json(
apihelper.create_chat_invite_link(self.token, chat_id, name, expire_date, member_limit, creates_join_request)
)

def edit_chat_invite_link(
self, chat_id: Union[int, str], name: Optional[str]=None,
invite_link: Optional[str] = None,
expire_date: Optional[Union[int, datetime]]=None,
member_limit: Optional[int]=None ,
self, chat_id: Union[int, str],
invite_link: Optional[str] = None,
name: Optional[str]=None,
expire_date: Optional[Union[int, datetime]]=None,
member_limit: Optional[int]=None,
creates_join_request: Optional[bool]=None) -> types.ChatInviteLink:
"""
Use this method to edit a non-primary invite link created by the bot.
The bot must be an administrator in the chat for this to work and must have the appropriate admin rights.
:param invite_link:
:param chat_id: Id: Unique identifier for the target chat or username of the target channel
(in the format @channelusername)
:param name: Invite link name; 0-32 characters
:param invite_link: The invite link to edit
:param expire_date: Point in time (Unix timestamp) when the link will expire
:param member_limit: Maximum number of users that can be members of the chat simultaneously
:param creates_join_request: True, if users joining the chat via the link need to be approved by chat administrators. If True, member_limit can't be specified
:return:
"""
return types.ChatInviteLink.de_json(
Expand Down
7 changes: 6 additions & 1 deletion telebot/apihelper.py
Original file line number Diff line number Diff line change
Expand Up @@ -1016,7 +1016,7 @@ def edit_chat_invite_link(token, chat_id, invite_link, name, expire_date, member
payload['member_limit'] = member_limit
if name:
payload['name'] = name
if creates_join_request:
if creates_join_request is not None:
payload['creates_join_request'] = creates_join_request

return _make_request(token, method_url, params=payload, method='post')
Expand All @@ -1036,20 +1036,25 @@ def export_chat_invite_link(token, chat_id):
payload = {'chat_id': chat_id}
return _make_request(token, method_url, params=payload, method='post')


def approve_chat_join_request(token, chat_id, user_id):
method_url = 'approveChatJoinRequest'
payload = {
'chat_id': chat_id,
'user_id': user_id
}
return _make_request(token, method_url, params=payload, method='post')


def decline_chat_join_request(token, chat_id, user_id):
method_url = 'declineChatJoinRequest'
payload = {
'chat_id': chat_id,
'user_id': user_id
}
return _make_request(token, method_url, params=payload, method='post')


def set_chat_photo(token, chat_id, photo):
method_url = 'setChatPhoto'
payload = {'chat_id': chat_id}
Expand Down
13 changes: 6 additions & 7 deletions telebot/types.py
Original file line number Diff line number Diff line change
Expand Up @@ -175,16 +175,15 @@ def de_json(cls, json_string):
obj = cls.check_json(json_string)
obj['chat'] = Chat.de_json(obj['chat'])
obj['from_user'] = User.de_json(obj['from'])
obj['invite_link'] = ChatInviteLink.de_json(obj['invite_link'])

obj['invite_link'] = ChatInviteLink.de_json(obj.get('invite_link'))
return cls(**obj)

def __init__(self, chat, from_user, date, bio=None, invite_link=None, **kwargs):
self.chat = Chat = chat
self.from_user: User = from_user
self.date: int = date
self.bio: Optional[str] = bio
self.invite_link: Optional[ChatInviteLink] = invite_link
self.chat = chat
self.from_user = from_user
self.date = date
self.bio = bio
self.invite_link = invite_link

class WebhookInfo(JsonDeserializable):
@classmethod
Expand Down

0 comments on commit 4ba2356

Please sign in to comment.