Compliance with Telegram Bot API 6.4
This commit is contained in:
parent
27f9d62cf9
commit
5c30dafd4c
@ -11,7 +11,7 @@ __author__ = "Davide Testa"
|
|||||||
__email__ = "davide@davte.it"
|
__email__ = "davide@davte.it"
|
||||||
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
|
__credits__ = ["Marco Origlia", "Nick Lee @Nickoala"]
|
||||||
__license__ = "GNU General Public License v3.0"
|
__license__ = "GNU General Public License v3.0"
|
||||||
__version__ = "2.8.11"
|
__version__ = "2.8.12"
|
||||||
__maintainer__ = "Davide Testa"
|
__maintainer__ = "Davide Testa"
|
||||||
__contact__ = "t.me/davte"
|
__contact__ = "t.me/davte"
|
||||||
|
|
||||||
|
@ -684,6 +684,7 @@ class TelegramBot:
|
|||||||
disable_notification: bool = None,
|
disable_notification: bool = None,
|
||||||
reply_to_message_id: int = None,
|
reply_to_message_id: int = None,
|
||||||
allow_sending_without_reply: bool = None,
|
allow_sending_without_reply: bool = None,
|
||||||
|
has_spoiler: bool = None,
|
||||||
reply_markup=None):
|
reply_markup=None):
|
||||||
"""Send a photo from file_id, HTTP url or file.
|
"""Send a photo from file_id, HTTP url or file.
|
||||||
|
|
||||||
@ -752,6 +753,7 @@ class TelegramBot:
|
|||||||
allow_sending_without_reply: bool = None,
|
allow_sending_without_reply: bool = None,
|
||||||
message_thread_id: int = None,
|
message_thread_id: int = None,
|
||||||
protect_content: bool = None,
|
protect_content: bool = None,
|
||||||
|
has_spoiler: bool = None,
|
||||||
reply_markup=None):
|
reply_markup=None):
|
||||||
"""Send a video from file_id, HTTP url or file.
|
"""Send a video from file_id, HTTP url or file.
|
||||||
|
|
||||||
@ -775,6 +777,7 @@ class TelegramBot:
|
|||||||
allow_sending_without_reply: bool = None,
|
allow_sending_without_reply: bool = None,
|
||||||
message_thread_id: int = None,
|
message_thread_id: int = None,
|
||||||
protect_content: bool = None,
|
protect_content: bool = None,
|
||||||
|
has_spoiler: bool = None,
|
||||||
reply_markup=None):
|
reply_markup=None):
|
||||||
"""Send animation files (GIF or H.264/MPEG-4 AVC video without sound).
|
"""Send animation files (GIF or H.264/MPEG-4 AVC video without sound).
|
||||||
|
|
||||||
@ -1010,7 +1013,8 @@ class TelegramBot:
|
|||||||
parameters=parameters
|
parameters=parameters
|
||||||
)
|
)
|
||||||
|
|
||||||
async def sendChatAction(self, chat_id: Union[int, str], action):
|
async def sendChatAction(self, chat_id: Union[int, str], action,
|
||||||
|
message_thread_id: int = None):
|
||||||
"""Fake a typing status or similar.
|
"""Fake a typing status or similar.
|
||||||
|
|
||||||
See https://core.telegram.org/bots/api#sendchataction for details.
|
See https://core.telegram.org/bots/api#sendchataction for details.
|
||||||
@ -2285,3 +2289,70 @@ class TelegramBot:
|
|||||||
'createInvoiceLink',
|
'createInvoiceLink',
|
||||||
parameters=locals()
|
parameters=locals()
|
||||||
)
|
)
|
||||||
|
|
||||||
|
async def editGeneralForumTopic(self, chat_id: Union[int, str], name: str):
|
||||||
|
"""Edit the name of the 'General' topic in a forum supergroup chat.
|
||||||
|
|
||||||
|
The bot must be an administrator in the chat for this to work and must
|
||||||
|
have can_manage_topics administrator rights.
|
||||||
|
Returns True on success.
|
||||||
|
See https://core.telegram.org/bots/api#editgeneralforumtopic for details.
|
||||||
|
"""
|
||||||
|
return await self.api_request(
|
||||||
|
'editGeneralForumTopic',
|
||||||
|
parameters=locals()
|
||||||
|
)
|
||||||
|
|
||||||
|
async def closeGeneralForumTopic(self, chat_id: Union[int, str]):
|
||||||
|
"""Close an open 'General' topic in a forum supergroup chat.
|
||||||
|
|
||||||
|
The bot must be an administrator in the chat for this to work and must
|
||||||
|
have the can_manage_topics administrator rights.
|
||||||
|
Returns True on success.
|
||||||
|
See https://core.telegram.org/bots/api#closegeneralforumtopic for details.
|
||||||
|
"""
|
||||||
|
return await self.api_request(
|
||||||
|
'closeGeneralForumTopic',
|
||||||
|
parameters=locals()
|
||||||
|
)
|
||||||
|
|
||||||
|
async def reopenGeneralForumTopic(self, chat_id: Union[int, str]):
|
||||||
|
"""Reopen a closed 'General' topic in a forum supergroup chat.
|
||||||
|
|
||||||
|
The bot must be an administrator in the chat for this to work and must
|
||||||
|
have the can_manage_topics administrator rights.
|
||||||
|
The topic will be automatically unhidden if it was hidden.
|
||||||
|
Returns True on success.
|
||||||
|
See https://core.telegram.org/bots/api#reopengeneralforumtopic for details.
|
||||||
|
"""
|
||||||
|
return await self.api_request(
|
||||||
|
'reopenGeneralForumTopic',
|
||||||
|
parameters=locals()
|
||||||
|
)
|
||||||
|
|
||||||
|
async def hideGeneralForumTopic(self, chat_id: Union[int, str]):
|
||||||
|
"""Hide the 'General' topic in a forum supergroup chat.
|
||||||
|
|
||||||
|
The bot must be an administrator in the chat for this to work and
|
||||||
|
must have the can_manage_topics administrator rights.
|
||||||
|
The topic will be automatically closed if it was open.
|
||||||
|
Returns True on success.
|
||||||
|
See https://core.telegram.org/bots/api#hidegeneralforumtopic for details.
|
||||||
|
"""
|
||||||
|
return await self.api_request(
|
||||||
|
'hideGeneralForumTopic',
|
||||||
|
parameters=locals()
|
||||||
|
)
|
||||||
|
|
||||||
|
async def unhideGeneralForumTopic(self, chat_id: Union[int, str]):
|
||||||
|
"""Unhide the 'General' topic in a forum supergroup chat.
|
||||||
|
|
||||||
|
The bot must be an administrator in the chat for this to work and must
|
||||||
|
have the can_manage_topics administrator rights.
|
||||||
|
Returns True on success.
|
||||||
|
See https://core.telegram.org/bots/api#unhidegeneralforumtopic for details.
|
||||||
|
"""
|
||||||
|
return await self.api_request(
|
||||||
|
'unhideGeneralForumTopic',
|
||||||
|
parameters=locals()
|
||||||
|
)
|
||||||
|
@ -46,6 +46,29 @@ class TelegramApiMethod(object):
|
|||||||
"""Return method description."""
|
"""Return method description."""
|
||||||
return self._description
|
return self._description
|
||||||
|
|
||||||
|
@property
|
||||||
|
def description_80chars(self):
|
||||||
|
"""Return method description, breaking lines at 80 characters."""
|
||||||
|
result, current_line = '', ''
|
||||||
|
indentation = 8
|
||||||
|
redundant_string = "Use this method to "
|
||||||
|
for n, paragraph in enumerate(self.description.replace('.', '.\n').split('\n')):
|
||||||
|
additional_indentation = 0
|
||||||
|
if n == 0 and paragraph.startswith(redundant_string):
|
||||||
|
paragraph = paragraph[len(redundant_string)].upper() + paragraph[len(redundant_string)+1:]
|
||||||
|
for word in paragraph.split(' '):
|
||||||
|
if len(current_line) + len(word) > 80 - indentation - additional_indentation:
|
||||||
|
additional_indentation = max(additional_indentation, 4)
|
||||||
|
result += f"{current_line.strip()}\n{' ' * additional_indentation}"
|
||||||
|
current_line = ""
|
||||||
|
current_line += f"{word} "
|
||||||
|
if len(current_line):
|
||||||
|
result += f"{current_line.strip()}\n"
|
||||||
|
current_line = ""
|
||||||
|
if n == 0:
|
||||||
|
result += '\n'
|
||||||
|
return result.strip()
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def table(self):
|
def table(self):
|
||||||
"""Return method parameters table."""
|
"""Return method parameters table."""
|
||||||
@ -193,7 +216,7 @@ async def print_api_methods(filename=None,
|
|||||||
f"{', '.join(['self'] + method.parameters_with_types)}"
|
f"{', '.join(['self'] + method.parameters_with_types)}"
|
||||||
f"):\n"
|
f"):\n"
|
||||||
f" \"\"\""
|
f" \"\"\""
|
||||||
f"{method.description.replace(new_line, new_line + ' ' * 4)}\n"
|
f"{method.description_80chars.replace(new_line, new_line + ' ' * 8)}\n"
|
||||||
f" See https://core.telegram.org/bots/api#"
|
f" See https://core.telegram.org/bots/api#"
|
||||||
f"{method.name.lower()} for details.\n"
|
f"{method.name.lower()} for details.\n"
|
||||||
f" \"\"\"\n"
|
f" \"\"\"\n"
|
||||||
|
Loading…
x
Reference in New Issue
Block a user