Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

API 4.5#1508

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Bibo-Joshi merged 38 commits intomasterfromnested-entities
Mar 28, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
Show all changes
38 commits
Select commitHold shift + click to select a range
1112343
Allow for nested MessageEntities in Message._parse_markdown/html, adj…
Aug 8, 2019
b4b47eb
remove testing relict
Bibo-JoshiAug 23, 2019
69708d3
Use MessageEntitys new equality check (#1465)
Bibo-JoshiAug 31, 2019
b3818b4
Remove unused variable
Bibo-JoshiAug 31, 2019
8816d5a
Update to custom_title feature and slow_mode_delay option
dmytrohoiJan 2, 2020
a58188d
Merge remote-tracking branch 'origin' into nested-entities
Bibo-JoshiJan 3, 2020
87e18c6
Minor typo fix
Bibo-JoshiJan 3, 2020
6c794ed
Merge pull request #1690 from dmytrohoi/patch-1
Bibo-JoshiJan 3, 2020
5cbd547
Comply with Flake8
Bibo-JoshiJan 3, 2020
598b6dd
Add new MessageEntities and MarkdownV2
Bibo-JoshiJan 4, 2020
d5e35eb
Added file_unique_id attrs from API 4.5 and updated tests for it
dmytrohoiJan 6, 2020
a29b666
Fixed test and checked using flake8
dmytrohoiJan 7, 2020
a2e498b
Fixed ChatPhoto documentation
dmytrohoiJan 8, 2020
e568b30
Merge pull request #1695 from dmytrohoi/nested-entities
Bibo-JoshiJan 8, 2020
1e48d96
Fix Flake8
Bibo-JoshiJan 8, 2020
0c29ecb
Add setChatAdminCstmTitle to Bot
Bibo-JoshiJan 8, 2020
b5f36f7
Rename MDV2 methods
Bibo-JoshiJan 11, 2020
a5daa63
Change files id attrs to unique id
Bibo-JoshiJan 26, 2020
5794117
correct id_attrs for chat_photo
Bibo-JoshiJan 28, 2020
8641ba8
Merge branch 'master' into nested-entities
Bibo-JoshiFeb 5, 2020
a0a2172
Revert "temporarily skip tests failing b/c missing api 4.5 (#1738)"
Bibo-JoshiFeb 5, 2020
d6a0902
Fix text_markdown_v2 for monospace and text_links
Bibo-JoshiFeb 5, 2020
06c269c
closing remarks from pieter
PoolitzerFeb 11, 2020
5b6d609
Merge master
Bibo-JoshiFeb 15, 2020
3e8b05e
Minor fix in escape_markdown, improve tests for it
Bibo-JoshiFeb 15, 2020
285cb37
Fix offset bug in Message._parse_*
Bibo-JoshiFeb 15, 2020
72a858c
Add test_chatphoto.py
Bibo-JoshiFeb 15, 2020
ffdb1df
remove debug print from test_message.py
Bibo-JoshiFeb 15, 2020
78a932e
try making codecov happy
Bibo-JoshiFeb 15, 2020
55eb0b8
Update readme
Bibo-JoshiFeb 15, 2020
278948d
all hail codecov
Bibo-JoshiFeb 15, 2020
3135199
Improve Link handling for MarkdownV1 and adjust tests. Closes #1654
Bibo-JoshiFeb 17, 2020
ec32296
Dont use beginning of pre-entity as language in _parse_markdown
Bibo-JoshiFeb 17, 2020
85c5cb5
Remove debug print
Bibo-JoshiFeb 17, 2020
14ac76e
Merge branch 'master' into nested-entities
Bibo-JoshiMar 6, 2020
fbc6b76
Merge branch 'master' into nested-entities
Bibo-JoshiMar 28, 2020
0629d88
Dummy commit to try fix codecov
Bibo-JoshiMar 28, 2020
f5eefcf
Merge branch 'master' into nested-entities
Bibo-JoshiMar 28, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletionREADME.rst
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -93,7 +93,7 @@ make the development of bots easy and straightforward. These classes are contain
Telegram API support
====================

All types and methods of the Telegram Bot API **4.1** are supported.
All types and methods of the Telegram Bot API **4.5** are supported.

==========
Installing
Expand Down
40 changes: 40 additions & 0 deletionstelegram/bot.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -2941,6 +2941,44 @@ def set_chat_permissions(self, chat_id, permissions, timeout=None, **kwargs):

return result

@log
def set_chat_administrator_custom_title(self,
chat_id,
user_id,
custom_title,
timeout=None,
**kwargs):
"""
Use this method to set a custom title for administrators promoted by the bot in a
supergroup. The bot must be an administrator for this to work. Returns True on success.

Args:
chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username of
the target supergroup (in the format `@supergroupusername`).
user_id (:obj:`int`): Unique identifier of the target administrator.
custom_title (:obj:`str`) New custom title for the administrator. It must be a string
with len 0-16 characters, emoji are not allowed.
timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
the read timeout from the server (instead of the one specified during creation of
the connection pool).
**kwargs (:obj:`dict`): Arbitrary keyword arguments

Returns:
:obj:`bool`: Returns True on success.

Raises:
:class:`telegram.TelegramError`

"""
url = '{0}/setChatAdministratorCustomTitle'.format(self.base_url)

data = {'chat_id': chat_id, 'user_id': user_id, 'custom_title': custom_title}
data.update(kwargs)

result = self._request.post(url, data, timeout=timeout)

return result

@log
def export_chat_invite_link(self, chat_id, timeout=None, **kwargs):
"""
Expand DownExpand Up@@ -3655,6 +3693,8 @@ def __reduce__(self):
"""Alias for :attr:`promote_chat_member`"""
setChatPermissions = set_chat_permissions
"""Alias for :attr:`set_chat_permissions`"""
setChatAdministratorCustomTitle = set_chat_administrator_custom_title
"""Alias for :attr:`set_chat_administrator_custom_title`"""
exportChatInviteLink = export_chat_invite_link
"""Alias for :attr:`export_chat_invite_link`"""
setChatPhoto = set_chat_photo
Expand Down
17 changes: 17 additions & 0 deletionstelegram/chat.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -40,6 +40,8 @@ class Chat(TelegramObject):
Returned only in get_chat.
permissions (:class:`telegram.ChatPermission`): Optional. Default chat member permissions,
for groups and supergroups. Returned only in getChat.
slow_mode_delay (:obj:`int`): Optional. For supergroups, the minimum allowed delay between
consecutive messages sent by each unpriviledged user. Returned only in getChat.
sticker_set_name (:obj:`str`): Optional. For supergroups, name of Group sticker set.
can_set_sticker_set (:obj:`bool`): Optional. ``True``, if the bot can change group the
sticker set.
Expand All@@ -65,6 +67,8 @@ class Chat(TelegramObject):
Returned only in get_chat.
permissions (:class:`telegram.ChatPermission`): Optional. Default chat member permissions,
for groups and supergroups. Returned only in getChat.
slow_mode_delay (:obj:`int`, optional): For supergroups, the minimum allowed delay between
consecutive messages sent by each unpriviledged user. Returned only in getChat.
bot (:class:`telegram.Bot`, optional): The Bot to use for instance methods.
sticker_set_name (:obj:`str`, optional): For supergroups, name of Group sticker set.
Returned only in get_chat.
Expand DownExpand Up@@ -98,6 +102,7 @@ def __init__(self,
permissions=None,
sticker_set_name=None,
can_set_sticker_set=None,
slow_mode_delay=None,
**kwargs):
# Required
self.id = int(id)
Expand All@@ -114,6 +119,7 @@ def __init__(self,
self.invite_link = invite_link
self.pinned_message = pinned_message
self.permissions = permissions
self.slow_mode_delay = slow_mode_delay
self.sticker_set_name = sticker_set_name
self.can_set_sticker_set = can_set_sticker_set

Expand DownExpand Up@@ -240,6 +246,17 @@ def set_permissions(self, *args, **kwargs):
"""
return self.bot.set_chat_permissions(self.id, *args, **kwargs)

def set_administrator_custom_title(self, *args, **kwargs):
"""Shortcut for::

bot.set_chat_administrator_custom_title(update.message.chat.id, *args, **kwargs)

Returns:
:obj:`bool`: If the action was sent successfully.

"""
return self.bot.set_chat_administrator_custom_title(self.id, *args, **kwargs)

def send_message(self, *args, **kwargs):
"""Shortcut for::

Expand Down
6 changes: 5 additions & 1 deletiontelegram/chatmember.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -28,6 +28,7 @@ class ChatMember(TelegramObject):
Attributes:
user (:class:`telegram.User`): Information about the user.
status (:obj:`str`): The member's status in the chat.
custom_title (:obj:`str`): Optional. Custom title for owner and administrators.
until_date (:class:`datetime.datetime`): Optional. Date when restrictions will be lifted
for this user.
can_be_edited (:obj:`bool`): Optional. If the bot is allowed to edit administrator
Expand DownExpand Up@@ -62,6 +63,8 @@ class ChatMember(TelegramObject):
user (:class:`telegram.User`): Information about the user.
status (:obj:`str`): The member's status in the chat. Can be 'creator', 'administrator',
'member', 'restricted', 'left' or 'kicked'.
custom_title (:obj:`str`, optional): Owner and administrators only.
Custom title for this user.
until_date (:class:`datetime.datetime`, optional): Restricted and kicked only. Date when
restrictions will be lifted for this user.
can_be_edited (:obj:`bool`, optional): Administrators only. True, if the bot is allowed to
Expand DownExpand Up@@ -118,10 +121,11 @@ def __init__(self, user, status, until_date=None, can_be_edited=None,
can_restrict_members=None, can_pin_messages=None,
can_promote_members=None, can_send_messages=None,
can_send_media_messages=None, can_send_polls=None, can_send_other_messages=None,
can_add_web_page_previews=None, is_member=None, **kwargs):
can_add_web_page_previews=None, is_member=None,custom_title=None,**kwargs):
# Required
self.user = user
self.status = status
self.custom_title = custom_title
self.until_date = until_date
self.can_be_edited = can_be_edited
self.can_change_info = can_change_info
Expand Down
14 changes: 11 additions & 3 deletionstelegram/files/animation.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,7 +25,10 @@ class Animation(TelegramObject):
"""This object represents an animation file to be displayed in the message containing a game.

Attributes:
file_id (:obj:`str`): Unique file identifier.
file_id (:obj:`str`): File identifier.
file_unique_id (:obj:`str`): Unique identifier for this file, which
is supposed to be the same over time and for different bots.
Can't be used to download or reuse the file.
width (:obj:`int`): Video width as defined by sender.
height (:obj:`int`): Video height as defined by sender.
duration (:obj:`int`): Duration of the video in seconds as defined by sender.
Expand All@@ -37,7 +40,10 @@ class Animation(TelegramObject):
bot (:class:`telegram.Bot`): Optional. The Bot to use for instance methods.

Args:
file_id (:obj:`str`): Unique file identifier.
file_id (:obj:`str`): Identifier for this file, which can be used to download
or reuse the file.
file_unique_id (:obj:`str`): Unique and the same over time and
for different bots file identifier.
width (:obj:`int`): Video width as defined by sender.
height (:obj:`int`): Video height as defined by sender.
duration (:obj:`int`): Duration of the video in seconds as defined by sender.
Expand All@@ -52,6 +58,7 @@ class Animation(TelegramObject):

def __init__(self,
file_id,
file_unique_id,
width,
height,
duration,
Expand All@@ -63,6 +70,7 @@ def __init__(self,
**kwargs):
# Required
self.file_id = str(file_id)
self.file_unique_id = str(file_unique_id)
self.width = int(width)
self.height = int(height)
self.duration = duration
Expand All@@ -73,7 +81,7 @@ def __init__(self,
self.file_size = file_size
self.bot = bot

self._id_attrs = (self.file_id,)
self._id_attrs = (self.file_unique_id,)

@classmethod
def de_json(cls, data, bot):
Expand Down
12 changes: 10 additions & 2 deletionstelegram/files/audio.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,6 +26,9 @@ class Audio(TelegramObject):

Attributes:
file_id (:obj:`str`): Unique identifier for this file.
file_unique_id (:obj:`str`): Unique identifier for this file, which
is supposed to be the same over time and for different bots.
Can't be used to download or reuse the file.
duration (:obj:`int`): Duration of the audio in seconds.
performer (:obj:`str`): Optional. Performer of the audio as defined by sender or by audio
tags.
Expand All@@ -37,7 +40,10 @@ class Audio(TelegramObject):
bot (:class:`telegram.Bot`): Optional. The Bot to use for instance methods.

Args:
file_id (:obj:`str`): Unique identifier for this file.
file_id (:obj:`str`): Identifier for this file, which can be used to download
or reuse the file.
file_unique_id (:obj:`str`): Unique and the same over time and
for different bots file identifier.
duration (:obj:`int`): Duration of the audio in seconds as defined by sender.
performer (:obj:`str`, optional): Performer of the audio as defined by sender or by audio
tags.
Expand All@@ -53,6 +59,7 @@ class Audio(TelegramObject):

def __init__(self,
file_id,
file_unique_id,
duration,
performer=None,
title=None,
Expand All@@ -63,6 +70,7 @@ def __init__(self,
**kwargs):
# Required
self.file_id = str(file_id)
self.file_unique_id = str(file_unique_id)
self.duration = int(duration)
# Optionals
self.performer = performer
Expand All@@ -72,7 +80,7 @@ def __init__(self,
self.thumb = thumb
self.bot = bot

self._id_attrs = (self.file_id,)
self._id_attrs = (self.file_unique_id,)

@classmethod
def de_json(cls, data, bot):
Expand Down
38 changes: 31 additions & 7 deletionstelegram/files/chatphoto.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -25,24 +25,48 @@ class ChatPhoto(TelegramObject):

Attributes:
small_file_id (:obj:`str`): File identifier of small (160x160) chat photo.
This file_id can be used only for photo download and only for as long
as the photo is not changed.
small_file_unique_id (:obj:`str`): Unique file identifier of small (160x160) chat photo,
which is supposed to be the same over time and for different bots.
Can't be used to download or reuse the file.
big_file_id (:obj:`str`): File identifier of big (640x640) chat photo.

This file_id can be used only for photo download and only for as long as
the photo is not changed.
big_file_unique_id (:obj:`str`): Unique file identifier of big (640x640) chat photo,
which is supposed to be the same over time and for different bots.
Can't be used to download or reuse the file.
Args:
small_file_id (:obj:`str`): File identifier of small (160x160) chat photo. This file_id can
be used only for photo download and only for as long as the photo is not changed.
big_file_id (:obj:`str`): File identifier of big (640x640) chat photo. This file_id can be
used only for photo download and only for as long as the photo is not changed.
small_file_id (:obj:`str`): Unique file identifier of small (160x160) chat photo. This
file_id can be used only for photo download and only for as long
as the photo is not changed.
small_file_unique_id (:obj:`str`): Unique file identifier of small (160x160) chat photo,
which is supposed to be the same over time and for different bots.
Can't be used to download or reuse the file.
big_file_id (:obj:`str`): Unique file identifier of big (640x640) chat photo. This file_id
can be used only for photo download and only for as long as the photo is not changed.
big_file_unique_id (:obj:`str`): Unique file identifier of big (640x640) chat photo,
which is supposed to be the same over time and for different bots.
Can't be used to download or reuse the file.
bot (:class:`telegram.Bot`, optional): The Bot to use for instance methods
**kwargs (:obj:`dict`): Arbitrary keyword arguments.

"""

def __init__(self, small_file_id, big_file_id, bot=None, **kwargs):
def __init__(self,
small_file_id,
small_file_unique_id,
big_file_id,
big_file_unique_id,
bot=None, **kwargs):
self.small_file_id = small_file_id
self.small_file_unique_id = small_file_unique_id
self.big_file_id = big_file_id
self.big_file_unique_id = big_file_unique_id

self.bot = bot

self._id_attrs = (self.small_file_id, self.big_file_id)
self._id_attrs = (self.small_file_unique_id, self.big_file_unique_id,)

@classmethod
def de_json(cls, data, bot):
Expand Down
12 changes: 10 additions & 2 deletionstelegram/files/document.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -26,14 +26,20 @@ class Document(TelegramObject):

Attributes:
file_id (:obj:`str`): Unique file identifier.
file_unique_id (:obj:`str`): Unique identifier for this file, which
is supposed to be the same over time and for different bots.
Can't be used to download or reuse the file.
thumb (:class:`telegram.PhotoSize`): Optional. Document thumbnail.
file_name (:obj:`str`): Original filename.
mime_type (:obj:`str`): Optional. MIME type of the file.
file_size (:obj:`int`): Optional. File size.
bot (:class:`telegram.Bot`): Optional. The Bot to use for instance methods.

Args:
file_id (:obj:`str`): Unique file identifier
file_id (:obj:`str`): Identifier for this file, which can be used to download
or reuse the file.
file_unique_id (:obj:`str`): Unique and the same over time and
for different bots file identifier.
thumb (:class:`telegram.PhotoSize`, optional): Document thumbnail as defined by sender.
file_name (:obj:`str`, optional): Original filename as defined by sender.
mime_type (:obj:`str`, optional): MIME type of the file as defined by sender.
Expand All@@ -46,6 +52,7 @@ class Document(TelegramObject):

def __init__(self,
file_id,
file_unique_id,
thumb=None,
file_name=None,
mime_type=None,
Expand All@@ -54,14 +61,15 @@ def __init__(self,
**kwargs):
# Required
self.file_id = str(file_id)
self.file_unique_id = str(file_unique_id)
# Optionals
self.thumb = thumb
self.file_name = file_name
self.mime_type = mime_type
self.file_size = file_size
self.bot = bot

self._id_attrs = (self.file_id,)
self._id_attrs = (self.file_unique_id,)

@classmethod
def de_json(cls, data, bot):
Expand Down
21 changes: 16 additions & 5 deletionstelegram/files/file.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -38,11 +38,17 @@ class File(TelegramObject):

Attributes:
file_id (:obj:`str`): Unique identifier for this file.
file_unique_id (:obj:`str`): Unique identifier for this file, which
is supposed to be the same over time and for different bots.
Can't be used to download or reuse the file.
file_size (:obj:`str`): Optional. File size.
file_path (:obj:`str`): Optional. File path. Use :attr:`download` to get the file.

Args:
file_id (:obj:`str`): Unique identifier for this file.
file_id (:obj:`str`): Identifier for this file, which can be used to download
or reuse the file.
file_unique_id (:obj:`str`): Unique and the same over time and
for different bots file identifier.
file_size (:obj:`int`, optional): Optional. File size, if known.
file_path (:obj:`str`, optional): File path. Use :attr:`download` to get the file.
bot (:obj:`telegram.Bot`, optional): Bot to use with shortcut method.
Expand All@@ -54,18 +60,23 @@ class File(TelegramObject):

"""

def __init__(self, file_id, bot=None, file_size=None, file_path=None, **kwargs):
def __init__(self,
file_id,
file_unique_id,
bot=None,
file_size=None,
file_path=None,
**kwargs):
# Required
self.file_id = str(file_id)

self.file_unique_id = str(file_unique_id)
# Optionals
self.file_size = file_size
self.file_path = file_path

self.bot = bot
self._credentials = None

self._id_attrs = (self.file_id,)
self._id_attrs = (self.file_unique_id,)

@classmethod
def de_json(cls, data, bot):
Expand Down
Loading

[8]ページ先頭

©2009-2025 Movatter.jp