Skip to content

Commit 7e31c28

Browse files
Added InputMediaLink, Link, and parameters to various classes
1 parent 12d25e2 commit 7e31c28

1 file changed

Lines changed: 74 additions & 6 deletions

File tree

telebot/types.py

Lines changed: 74 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,10 @@ class ChatJoinRequest(JsonDeserializable):
391391
:param invite_link: Optional. Chat invite link that was used by the user to send the join request
392392
:type invite_link: :class:`telebot.types.ChatInviteLink`
393393

394+
:param query_id: Optional. Identifier of the join request query; for bots assigned to process join request only.
395+
If present, then the bot must call sendChatJoinRequestWebApp or directly call answerChatJoinRequestQuery within 10 seconds.
396+
:type query_id: :obj:`int`
397+
394398
:return: Instance of the class
395399
:rtype: :class:`telebot.types.ChatJoinRequest`
396400
"""
@@ -403,13 +407,14 @@ def de_json(cls, json_string):
403407
obj['invite_link'] = ChatInviteLink.de_json(obj.get('invite_link'))
404408
return cls(**obj)
405409

406-
def __init__(self, chat, from_user, user_chat_id, date, bio=None, invite_link=None, **kwargs):
410+
def __init__(self, chat, from_user, user_chat_id, date, bio=None, invite_link=None, query_id=None, **kwargs):
407411
self.chat: Chat = chat
408412
self.from_user: User = from_user
409413
self.date: str = date
410414
self.bio: Optional[str] = bio
411415
self.invite_link: Optional[ChatInviteLink] = invite_link
412416
self.user_chat_id: int = user_chat_id
417+
self.query_id: Optional[int] = query_id
413418

414419

415420
class WebhookInfo(JsonDeserializable):
@@ -533,6 +538,9 @@ class User(JsonDeserializable, Dictionaryable, JsonSerializable):
533538
:param can_manage_bots: Optional. True, if other bots can be created to be controlled by the bot. Returned only in getMe.
534539
:type can_manage_bots: :obj:`bool`
535540

541+
:param supports_join_request_queries: Optional. True, if the bot supports join request queries and can be assigned to process them. Returned only in getMe.
542+
:type supports_join_request_queries: :obj:`bool`
543+
536544
:return: Instance of the class
537545
:rtype: :class:`telebot.types.User`
538546
"""
@@ -547,7 +555,7 @@ def __init__(self, id, is_bot, first_name, last_name=None, username=None, langua
547555
can_join_groups=None, can_read_all_group_messages=None, supports_inline_queries=None,
548556
is_premium=None, added_to_attachment_menu=None, can_connect_to_business=None,
549557
has_main_web_app=None, has_topics_enabled=None, allows_users_to_create_topics=None, can_manage_bots=None,
550-
supports_guest_queries=None, **kwargs):
558+
supports_guest_queries=None, supports_join_request_queries=None, **kwargs):
551559
self.id: int = id
552560
self.is_bot: bool = is_bot
553561
self.first_name: str = first_name
@@ -565,6 +573,7 @@ def __init__(self, id, is_bot, first_name, last_name=None, username=None, langua
565573
self.allows_users_to_create_topics: Optional[bool] = allows_users_to_create_topics
566574
self.can_manage_bots: Optional[bool] = can_manage_bots
567575
self.supports_guest_queries: Optional[bool] = supports_guest_queries
576+
self.supports_join_request_queries: Optional[bool] = supports_join_request_queries
568577

569578
@property
570579
def full_name(self) -> str:
@@ -596,7 +605,8 @@ def to_dict(self):
596605
'has_topics_enabled': self.has_topics_enabled,
597606
'allows_users_to_create_topics': self.allows_users_to_create_topics,
598607
'can_manage_bots': self.can_manage_bots,
599-
'supports_guest_queries': self.supports_guest_queries
608+
'supports_guest_queries': self.supports_guest_queries,
609+
'supports_join_request_queries': self.supports_join_request_queries
600610
}
601611

602612

@@ -787,6 +797,9 @@ class ChatFullInfo(JsonDeserializable):
787797
:param unique_gift_colors: Optional. The color scheme based on a unique gift that must be used for the chat's name, message replies and link previews
788798
:type unique_gift_colors: :class:`telebot.types.UniqueGiftColors`
789799

800+
:param guard_bot: Optional. The bot that processes join request queries in the chat. The field is only available to chat administrators.
801+
:type guard_bot: :class:`telebot.types.User`
802+
790803
:return: Instance of the class
791804
:rtype: :class:`telebot.types.ChatFullInfo`
792805
"""
@@ -824,6 +837,8 @@ def de_json(cls, json_string):
824837
obj['unique_gift_colors'] = UniqueGiftColors.de_json(obj['unique_gift_colors'])
825838
if 'first_profile_audio' in obj:
826839
obj['first_profile_audio'] = Audio.de_json(obj['first_profile_audio'])
840+
if 'guard_bot' in obj:
841+
obj['guard_bot'] = User.de_json(obj['guard_bot'])
827842
return cls(**obj)
828843

829844
def __init__(self, id, type, title=None, username=None, first_name=None,
@@ -841,7 +856,7 @@ def __init__(self, id, type, title=None, username=None, first_name=None,
841856
business_opening_hours=None, personal_chat=None, birthdate=None,
842857
can_send_paid_media=None,
843858
accepted_gift_types=None, is_direct_messages=None, parent_chat=None, rating=None, paid_message_star_count=None,
844-
unique_gift_colors=None, first_profile_audio=None, **kwargs):
859+
unique_gift_colors=None, first_profile_audio=None, guard_bot=None, **kwargs):
845860
self.id: int = id
846861
self.type: str = type
847862
self.title: Optional[str] = title
@@ -893,6 +908,7 @@ def __init__(self, id, type, title=None, username=None, first_name=None,
893908
self.paid_message_star_count: Optional[int] = paid_message_star_count
894909
self.unique_gift_colors: Optional[UniqueGiftColors] = unique_gift_colors
895910
self.first_profile_audio: Optional[Audio] = first_profile_audio
911+
self.guard_bot: Optional[User] = guard_bot
896912

897913

898914
@property
@@ -14426,6 +14442,9 @@ class PollMedia(JsonDeserializable):
1442614442
:param document: Optional. Media is a general file, information about the file; currently, can't be received in a poll option
1442714443
:type document: :class:`Document`
1442814444

14445+
:param link: Optional. The HTTP link attached to the poll option
14446+
:type link: :class:`Link`
14447+
1442914448
:param live_photo: Optional. Media is a live photo, information about the live photo
1443014449
:type live_photo: :class:`LivePhoto`
1443114450

@@ -14450,7 +14469,7 @@ class PollMedia(JsonDeserializable):
1445014469
"""
1445114470
def __init__(self, animation: Optional[Animation] = None, audio: Optional[Audio] = None, document: Optional[Document] = None,
1445214471
live_photo: Optional[LivePhoto] = None, location: Optional[Location] = None, photo: Optional[List[PhotoSize]] = None,
14453-
sticker: Optional[Sticker] = None, venue: Optional[Venue] = None, video: Optional[Video] = None, **kwargs):
14472+
sticker: Optional[Sticker] = None, venue: Optional[Venue] = None, video: Optional[Video] = None, link: Optional[Link] = None):
1445414473
self.animation: Optional[Animation] = animation
1445514474
self.audio: Optional[Audio] = audio
1445614475
self.document: Optional[Document] = document
@@ -14460,6 +14479,7 @@ def __init__(self, animation: Optional[Animation] = None, audio: Optional[Audio]
1446014479
self.sticker: Optional[Sticker] = sticker
1446114480
self.venue: Optional[Venue] = venue
1446214481
self.video: Optional[Video] = video
14482+
self.link: Optional[Link] = link
1446314483

1446414484
@classmethod
1446514485
def de_json(cls, json_string):
@@ -14483,12 +14503,40 @@ def de_json(cls, json_string):
1448314503
obj['venue'] = Venue.de_json(obj['venue'])
1448414504
if 'video' in obj:
1448514505
obj['video'] = Video.de_json(obj['video'])
14506+
if 'link' in obj:
14507+
obj['link'] = Link.de_json(obj['link'])
1448614508
return cls(**obj)
1448714509

14510+
14511+
class InputMediaLink(JsonDeserializable):
14512+
"""
14513+
This object represents an HTTP link to be sent.
14514+
14515+
Telegram documentation: https://core.telegram.org/bots/api#inputmedialink
14516+
14517+
:param url: HTTP URL of the link
14518+
:type url: :obj:`str`
14519+
14520+
:return: Instance of the class
14521+
:rtype: :class:`InputMediaLink`
14522+
"""
14523+
def __init__(self, url: str, **kwargs):
14524+
self.url: str = url
14525+
14526+
def to_json(self):
14527+
return json.dumps(self.to_dict())
14528+
14529+
def to_dict(self):
14530+
return {
14531+
'type': 'link',
14532+
'url': self.url
14533+
}
14534+
14535+
1448814536
# why not..
1448914537
InputPollMedia = Union[InputMediaAnimation, InputMediaAudio, InputMediaDocument, InputMediaLivePhoto, InputMediaLocation, InputMediaPhoto, InputMediaVenue, InputMediaVideo]
1449014538

14491-
InputPollOptionMedia = Union[InputMediaAnimation, InputMediaLivePhoto, InputMediaLocation, InputMediaPhoto, InputMediaSticker, InputMediaVenue, InputMediaVideo]
14539+
InputPollOptionMedia = Union[InputMediaAnimation, InputMediaLivePhoto, InputMediaLocation, InputMediaPhoto, InputMediaSticker, InputMediaVenue, InputMediaVideo, InputMediaLink]
1449214540

1449314541

1449414542
class LivePhoto(JsonDeserializable):
@@ -16319,4 +16367,24 @@ def to_json(self) -> str:
1631916367
return json.dumps(self.to_dict())
1632016368

1632116369

16370+
class Link(JsonDeserializable):
16371+
"""
16372+
This object represents an HTTP link.
16373+
16374+
Telegram documentation: https://core.telegram.org/bots/api#link
16375+
16376+
:param url: URL of the link
16377+
:type url: :obj:`str`
16378+
16379+
:return: Instance of the class
16380+
:rtype: :class:`Link`
16381+
"""
16382+
def __init__(self, url: str, **kwargs):
16383+
self.url: str = url
1632216384

16385+
@classmethod
16386+
def de_json(cls, json_string):
16387+
if json_string is None: return None
16388+
obj = cls.check_json(json_string)
16389+
return cls(**obj)
16390+

0 commit comments

Comments
 (0)