Skip to content

Commit 60d581f

Browse files
committed
Fix UserShared with UsersShared
1 parent e2f5311 commit 60d581f

File tree

1 file changed

+14
-40
lines changed

1 file changed

+14
-40
lines changed

telebot/types.py

Lines changed: 14 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -992,7 +992,7 @@ class Message(JsonDeserializable):
992992
:type successful_payment: :class:`telebot.types.SuccessfulPayment`
993993
994994
:param users_shared: Optional. Service message: a user was shared with the bot
995-
:type users_shared: :class:`telebot.types.UserShared`
995+
:type users_shared: :class:`telebot.types.UsersShared`
996996
997997
:param chat_shared: Optional. Service message: a chat was shared with the bot
998998
:type chat_shared: :class:`telebot.types.ChatShared`
@@ -1242,7 +1242,7 @@ def de_json(cls, json_string):
12421242
opts['write_access_allowed'] = WriteAccessAllowed.de_json(obj['write_access_allowed'])
12431243
content_type = 'write_access_allowed'
12441244
if 'users_shared' in obj:
1245-
opts['users_shared'] = UserShared.de_json(obj['users_shared'])
1245+
opts['users_shared'] = UsersShared.de_json(obj['users_shared'])
12461246
content_type = 'users_shared' # COMPATIBILITY BROKEN!
12471247
if 'chat_shared' in obj:
12481248
opts['chat_shared'] = ChatShared.de_json(obj['chat_shared'])
@@ -1359,8 +1359,7 @@ def __init__(self, message_id, from_user, date, chat, content_type, options, jso
13591359
self.general_forum_topic_hidden: Optional[GeneralForumTopicHidden] = None
13601360
self.general_forum_topic_unhidden: Optional[GeneralForumTopicUnhidden] = None
13611361
self.write_access_allowed: Optional[WriteAccessAllowed] = None
1362-
self.users_shared: Optional[UserShared] = None
1363-
self.user_shared: Optional[UserShared] = self.users_shared
1362+
self.users_shared: Optional[UsersShared] = None
13641363
self.chat_shared: Optional[ChatShared] = None
13651364
self.story: Optional[Story] = None
13661365
self.external_reply: Optional[ExternalReplyInfo] = None
@@ -1561,6 +1560,10 @@ def forward_date(self):
15611560
return self.forward_origin.date
15621561
return None
15631562

1563+
@property
1564+
def user_shared(self):
1565+
logger.warning('The parameter "user_shared" is deprecated, use "users_shared" instead')
1566+
return self.users_shared
15641567

15651568

15661569
class MessageEntity(Dictionaryable, JsonSerializable, JsonDeserializable):
@@ -2464,7 +2467,7 @@ class KeyboardButtonRequestUsers(Dictionaryable):
24642467
24652468
Telegram documentation: https://core.telegram.org/bots/api#keyboardbuttonrequestusers
24662469
2467-
:param request_id: Signed 32-bit identifier of the request, which will be received back in the UserShared object.
2470+
:param request_id: Signed 32-bit identifier of the request, which will be received back in the UsersShared object.
24682471
Must be unique within the message
24692472
:type request_id: :obj:`int`
24702473
@@ -2601,7 +2604,7 @@ class KeyboardButton(Dictionaryable, JsonSerializable):
26012604
:type web_app: :class:`telebot.types.WebAppInfo`
26022605
26032606
:param request_user: Optional. If specified, pressing the button will open a list of suitable users. Tapping on any user
2604-
will send their identifier to the bot in a “user_shared” service message. Available in private chats only.
2607+
will send their identifier to the bot in a “users_shared” service message. Available in private chats only.
26052608
:type request_user: :class:`telebot.types.KeyboardButtonRequestUsers`
26062609
26072610
:param request_chat: Optional. If specified, pressing the button will open a list of suitable chats. Tapping on a chat will
@@ -7732,41 +7735,8 @@ def __init__(self, from_request: Optional[bool]=None, web_app_name: Optional[str
77327735
self.web_app_name: str = web_app_name
77337736
self.from_request: bool = from_request
77347737
self.from_attachment_menu: bool = from_attachment_menu
7735-
7736-
7737-
7738-
class UserShared(JsonDeserializable):
7739-
"""
7740-
This object contains information about the user whose identifier was shared with the bot using a
7741-
`telebot.types.KeyboardButtonRequestUsers` button.
7742-
7743-
Telegram documentation: https://core.telegram.org/bots/api#usershared
77447738

7745-
:param request_id: identifier of the request
7746-
:type request_id: :obj:`int`
77477739

7748-
:param user_id: Identifier of the shared user. This number may have more than 32 significant bits and some programming
7749-
languages may have difficulty/silent defects in interpreting it. But it has at most 52 significant bits, so a 64-bit
7750-
integer or double-precision float type are safe for storing this identifier. The bot may not have access to the user
7751-
and could be unable to use this identifier, unless the user is already known to the bot by some other means.
7752-
:type user_id: :obj:`int`
7753-
7754-
:return: Instance of the class
7755-
:rtype: :class:`telebot.types.UserShared`
7756-
"""
7757-
7758-
@classmethod
7759-
def de_json(cls, json_string):
7760-
if json_string is None: return None
7761-
obj = cls.check_json(json_string)
7762-
return cls(**obj)
7763-
7764-
def __init__(self, request_id: int, user_id: int, **kwargs) -> None:
7765-
self.request_id: int = request_id
7766-
self.user_id: int = user_id
7767-
7768-
7769-
77707740
class ChatShared(JsonDeserializable):
77717741
"""
77727742
This object contains information about the chat whose identifier was shared with the bot using a
@@ -8918,7 +8888,6 @@ class UsersShared(JsonDeserializable):
89188888
:return: Instance of the class
89198889
:rtype: :class:`UsersShared`
89208890
"""
8921-
89228891
@classmethod
89238892
def de_json(cls, json_string):
89248893
if json_string is None:
@@ -8929,6 +8898,11 @@ def de_json(cls, json_string):
89298898
def __init__(self, request_id, user_ids, **kwargs):
89308899
self.request_id = request_id
89318900
self.user_ids = user_ids
8901+
8902+
@property
8903+
def user_id(self):
8904+
logger.warning('The parameter "user_id" is deprecated, use "user_ids" instead')
8905+
return None
89328906

89338907

89348908
class ChatBoostUpdated(JsonDeserializable):

0 commit comments

Comments
 (0)