-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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 8.2 full support #2440
Bot API 8.2 full support #2440
Changes from 1 commit
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 |
---|---|---|
|
@@ -7707,7 +7707,8 @@ async def delete_sticker_set(self, name:str) -> bool: | |
|
||
return await asyncio_helper.delete_sticker_set(self.token, name) | ||
|
||
async def send_gift(self, user_id: int, gift_id: str, text: Optional[str]=None, text_parse_mode: Optional[str]=None, text_entities: Optional[List[types.MessageEntity]]=None) -> bool: | ||
async def send_gift(self, user_id: int, gift_id: str, text: Optional[str]=None, text_parse_mode: Optional[str]=None, | ||
text_entities: Optional[List[types.MessageEntity]]=None, pay_for_upgrade: Optional[bool]=None) -> bool: | ||
""" | ||
Sends a gift to the given user. The gift can't be converted to Telegram Stars by the user. Returns True on success. | ||
|
||
|
@@ -7719,6 +7720,9 @@ async def send_gift(self, user_id: int, gift_id: str, text: Optional[str]=None, | |
:param gift_id: Identifier of the gift | ||
:type gift_id: :obj:`str` | ||
|
||
:param pay_for_upgrade: Pass True to pay for the gift upgrade from the bot's balance, thereby making the upgrade free for the receiver | ||
:type pay_for_upgrade: :obj:`bool` | ||
|
||
:param text: Text that will be shown along with the gift; 0-255 characters | ||
:type text: :obj:`str` | ||
|
||
|
@@ -7731,7 +7735,71 @@ async def send_gift(self, user_id: int, gift_id: str, text: Optional[str]=None, | |
:return: Returns True on success. | ||
:rtype: :obj:`bool` | ||
""" | ||
return await asyncio_helper.send_gift(self.token, user_id, gift_id, text, text_parse_mode, text_entities) | ||
return await asyncio_helper.send_gift(self.token, user_id, gift_id, text, text_parse_mode, text_entities, pay_for_upgrade=pay_for_upgrade) | ||
|
||
async def verify_user(self, user_id: int, custom_description: Optional[str]=None) -> bool: | ||
""" | ||
Verifies a user on behalf of the organization which is represented by the bot. Returns True on success. | ||
|
||
Telegram documentation: https://core.telegram.org/bots/api#verifyuser | ||
|
||
:param user_id: Unique identifier of the target user | ||
:type user_id: :obj:`int` | ||
|
||
:param custom_description: Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description. | ||
:type custom_description: :obj:`str` | ||
|
||
:return: Returns True on success. | ||
:rtype: :obj:`bool` | ||
""" | ||
return await asyncio_helper.verify_user(self.token, user_id, custom_description) | ||
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. May be it's time to start sending optional parameters as named? |
||
|
||
async def verify_chat(self, chat_id: Union[int, str], custom_description: Optional[str]=None) -> bool: | ||
""" | ||
Verifies a chat on behalf of the organization which is represented by the bot. Returns True on success. | ||
|
||
Telegram documentation: https://core.telegram.org/bots/api#verifychat | ||
|
||
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) | ||
:type chat_id: :obj:`int` | :obj:`str` | ||
|
||
:param custom_description: Custom description for the verification; 0-70 characters. Must be empty if the organization isn't allowed to provide a custom verification description. | ||
:type custom_description: :obj:`str` | ||
|
||
:return: Returns True on success. | ||
:rtype: :obj:`bool` | ||
""" | ||
|
||
return await asyncio_helper.verify_chat(self.token, chat_id, custom_description) | ||
|
||
async def remove_user_verification(self, user_id: int) -> bool: | ||
""" | ||
Removes verification from a user who is currently verified on behalf of the organization represented by the bot. Returns True on success. | ||
|
||
Telegram documentation: https://core.telegram.org/bots/api#removeuserverification | ||
|
||
:param user_id: Unique identifier of the target user | ||
:type user_id: :obj:`int` | ||
|
||
:return: Returns True on success. | ||
:rtype: :obj:`bool` | ||
|
||
""" | ||
return await asyncio_helper.remove_user_verification(self.token, user_id) | ||
|
||
async def remove_chat_verification(self, chat_id: Union[int, str]) -> bool: | ||
""" | ||
Removes verification from a chat that is currently verified on behalf of the organization represented by the bot. Returns True on success. | ||
|
||
Telegram documentation: https://core.telegram.org/bots/api#removechatverification | ||
|
||
:param chat_id: Unique identifier for the target chat or username of the target channel (in the format @channelusername) | ||
:type chat_id: :obj:`int` | :obj:`str` | ||
|
||
:return: Returns True on success. | ||
:rtype: :obj:`bool` | ||
""" | ||
return await asyncio_helper.remove_chat_verification(self.token, chat_id) | ||
|
||
async def get_available_gifts(self) -> types.Gifts: | ||
""" | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1916,7 +1916,7 @@ async def delete_sticker_set(token, name): | |
payload = {'name': name} | ||
return await _process_request(token, method_url, params=payload, method='post') | ||
|
||
async def send_gift(token, user_id, gift_id, text=None, text_parse_mode=None, text_entities=None): | ||
async def send_gift(token, user_id, gift_id, text=None, text_parse_mode=None, text_entities=None, pay_for_upgrade=None): | ||
method_url = 'sendGift' | ||
payload = {'user_id': user_id, 'gift_id': gift_id} | ||
if text: | ||
|
@@ -1925,6 +1925,32 @@ async def send_gift(token, user_id, gift_id, text=None, text_parse_mode=None, te | |
payload['text_parse_mode'] = text_parse_mode | ||
if text_entities: | ||
payload['text_entities'] = json.dumps(types.MessageEntity.to_list_of_dicts(text_entities)) | ||
if pay_for_upgrade is not None: | ||
payload['pay_for_upgrade'] = pay_for_upgrade | ||
return await _process_request(token, method_url, params=payload, method='post') | ||
|
||
async def verify_user(token, user_id, custom_description=None): | ||
method_url = 'verifyUser' | ||
payload = {'user_id': user_id} | ||
if custom_description: | ||
payload['custom_description'] = custom_description | ||
return await _process_request(token, method_url, params=payload, method='post') | ||
|
||
async def verify_chat(token, chat_id, custom_description=None): | ||
method_url = 'verifyChat' | ||
payload = {'chat_id': chat_id} | ||
if custom_description: | ||
payload['custom_description'] = custom_description | ||
return await _process_request(token, method_url, params=payload, method='post') | ||
|
||
async def remove_user_verification(token, user_id): | ||
method_url = 'removeUserVerification' | ||
payload = {'user_id': user_id} | ||
return await _process_request(token, method_url, params=payload, method='post') | ||
|
||
async def remove_chat_verification(token, chat_id): | ||
method_url = 'removeChatVerification' | ||
payload = {'chat_id': chat_id} | ||
return await _process_request(token, method_url, params=payload, method='post') | ||
|
||
async def get_available_gifts(token): | ||
|
@@ -2243,12 +2269,6 @@ async def convert_input_media_array(array): | |
if media_dict['media'].startswith('attach://'): | ||
key = media_dict['media'].replace('attach://', '') | ||
files[key] = input_media.media | ||
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. The same here: what is the reason for removing this code? |
||
if 'thumbnail' in media_dict: | ||
thumbnail = media_dict['thumbnail'] | ||
if isinstance(thumbnail, types.InputFile): | ||
thumbnail_key = 'thumbnail_' + key | ||
files[thumbnail_key] = thumbnail | ||
media_dict['thumbnail'] = 'attach://' + thumbnail_key | ||
media.append(media_dict) | ||
return json.dumps(media), files | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
# Versions should comply with PEP440. | ||
# This line is parsed in setup.py: | ||
__version__ = '4.25.0' | ||
__version__ = '4.24.0' | ||
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. Version downgraded. |
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.
What is the reason for removing this code?