@@ -3985,6 +3985,8 @@ def create_chat_invite_link(
3985
3985
member_limit : int = None ,
3986
3986
timeout : ODVInput [float ] = DEFAULT_NONE ,
3987
3987
api_kwargs : JSONDict = None ,
3988
+ name : str = None ,
3989
+ creates_join_request : bool = None ,
3988
3990
) -> ChatInviteLink :
3989
3991
"""
3990
3992
Use this method to create an additional invite link for a chat. The bot must be an
@@ -4007,6 +4009,14 @@ def create_chat_invite_link(
4007
4009
the connection pool).
4008
4010
api_kwargs (:obj:`dict`, optional): Arbitrary keyword arguments to be passed to the
4009
4011
Telegram API.
4012
+ name (:obj:`str`, optional): Invite link name; 0-32 characters.
4013
+
4014
+ .. versionadded:: 13.8
4015
+ creates_join_request (:obj:`bool`, optional): :obj:`True`, if users joining the chat
4016
+ via the link need to be approved by chat administrators.
4017
+ If :obj:`True`, ``member_limit`` can't be specified.
4018
+
4019
+ .. versionadded:: 13.8
4010
4020
4011
4021
Returns:
4012
4022
:class:`telegram.ChatInviteLink`
@@ -4015,6 +4025,11 @@ def create_chat_invite_link(
4015
4025
:class:`telegram.error.TelegramError`
4016
4026
4017
4027
"""
4028
+ if creates_join_request and member_limit :
4029
+ raise ValueError (
4030
+ "If `creates_join_request` is `True`, `member_limit` can't be specified."
4031
+ )
4032
+
4018
4033
data : JSONDict = {
4019
4034
'chat_id' : chat_id ,
4020
4035
}
@@ -4029,6 +4044,12 @@ def create_chat_invite_link(
4029
4044
if member_limit is not None :
4030
4045
data ['member_limit' ] = member_limit
4031
4046
4047
+ if name is not None :
4048
+ data ['name' ] = name
4049
+
4050
+ if creates_join_request is not None :
4051
+ data ['creates_join_request' ] = creates_join_request
4052
+
4032
4053
result = self ._post ('createChatInviteLink' , data , timeout = timeout , api_kwargs = api_kwargs )
4033
4054
4034
4055
return ChatInviteLink .de_json (result , self ) # type: ignore[return-value, arg-type]
@@ -4042,11 +4063,19 @@ def edit_chat_invite_link(
4042
4063
member_limit : int = None ,
4043
4064
timeout : ODVInput [float ] = DEFAULT_NONE ,
4044
4065
api_kwargs : JSONDict = None ,
4066
+ name : str = None ,
4067
+ creates_join_request : bool = None ,
4045
4068
) -> ChatInviteLink :
4046
4069
"""
4047
4070
Use this method to edit a non-primary invite link created by the bot. The bot must be an
4048
4071
administrator in the chat for this to work and must have the appropriate admin rights.
4049
4072
4073
+ Note:
4074
+ Though not stated explicitly in the official docs, Telegram changes not only the
4075
+ optional parameters that are explicitly passed, but also replaces all other optional
4076
+ parameters to the default values. However, since not documented, this behaviour may
4077
+ change unbeknown to PTB.
4078
+
4050
4079
.. versionadded:: 13.4
4051
4080
4052
4081
Args:
@@ -4064,6 +4093,14 @@ def edit_chat_invite_link(
4064
4093
the connection pool).
4065
4094
api_kwargs (:obj:`dict`, optional): Arbitrary keyword arguments to be passed to the
4066
4095
Telegram API.
4096
+ name (:obj:`str`, optional): Invite link name; 0-32 characters.
4097
+
4098
+ .. versionadded:: 13.8
4099
+ creates_join_request (:obj:`bool`, optional): :obj:`True`, if users joining the chat
4100
+ via the link need to be approved by chat administrators.
4101
+ If :obj:`True`, ``member_limit`` can't be specified.
4102
+
4103
+ .. versionadded:: 13.8
4067
4104
4068
4105
Returns:
4069
4106
:class:`telegram.ChatInviteLink`
@@ -4072,6 +4109,11 @@ def edit_chat_invite_link(
4072
4109
:class:`telegram.error.TelegramError`
4073
4110
4074
4111
"""
4112
+ if creates_join_request and member_limit :
4113
+ raise ValueError (
4114
+ "If `creates_join_request` is `True`, `member_limit` can't be specified."
4115
+ )
4116
+
4075
4117
data : JSONDict = {'chat_id' : chat_id , 'invite_link' : invite_link }
4076
4118
4077
4119
if expire_date is not None :
@@ -4084,6 +4126,12 @@ def edit_chat_invite_link(
4084
4126
if member_limit is not None :
4085
4127
data ['member_limit' ] = member_limit
4086
4128
4129
+ if name is not None :
4130
+ data ['name' ] = name
4131
+
4132
+ if creates_join_request is not None :
4133
+ data ['creates_join_request' ] = creates_join_request
4134
+
4087
4135
result = self ._post ('editChatInviteLink' , data , timeout = timeout , api_kwargs = api_kwargs )
4088
4136
4089
4137
return ChatInviteLink .de_json (result , self ) # type: ignore[return-value, arg-type]
@@ -4126,6 +4174,80 @@ def revoke_chat_invite_link(
4126
4174
4127
4175
return ChatInviteLink .de_json (result , self ) # type: ignore[return-value, arg-type]
4128
4176
4177
+ @log
4178
+ def approve_chat_join_request (
4179
+ self ,
4180
+ chat_id : Union [str , int ],
4181
+ user_id : int ,
4182
+ timeout : ODVInput [float ] = DEFAULT_NONE ,
4183
+ api_kwargs : JSONDict = None ,
4184
+ ) -> bool :
4185
+ """Use this method to approve a chat join request.
4186
+
4187
+ The bot must be an administrator in the chat for this to work and must have the
4188
+ :attr:`telegram.ChatPermissions.can_invite_users` administrator right.
4189
+
4190
+ .. versionadded:: 13.8
4191
+
4192
+ Args:
4193
+ chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
4194
+ of the target channel (in the format ``@channelusername``).
4195
+ user_id (:obj:`int`): Unique identifier of the target user.
4196
+ timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
4197
+ the read timeout from the server (instead of the one specified during creation of
4198
+ the connection pool).
4199
+ api_kwargs (:obj:`dict`, optional): Arbitrary keyword arguments to be passed to the
4200
+ Telegram API.
4201
+
4202
+ Returns:
4203
+ :obj:`bool`: On success, :obj:`True` is returned.
4204
+
4205
+ Raises:
4206
+ :class:`telegram.error.TelegramError`
4207
+ """
4208
+ data : JSONDict = {'chat_id' : chat_id , 'user_id' : user_id }
4209
+
4210
+ result = self ._post ('approveChatJoinRequest' , data , timeout = timeout , api_kwargs = api_kwargs )
4211
+
4212
+ return result # type: ignore[return-value]
4213
+
4214
+ @log
4215
+ def decline_chat_join_request (
4216
+ self ,
4217
+ chat_id : Union [str , int ],
4218
+ user_id : int ,
4219
+ timeout : ODVInput [float ] = DEFAULT_NONE ,
4220
+ api_kwargs : JSONDict = None ,
4221
+ ) -> bool :
4222
+ """Use this method to decline a chat join request.
4223
+
4224
+ The bot must be an administrator in the chat for this to work and must have the
4225
+ :attr:`telegram.ChatPermissions.can_invite_users` administrator right.
4226
+
4227
+ .. versionadded:: 13.8
4228
+
4229
+ Args:
4230
+ chat_id (:obj:`int` | :obj:`str`): Unique identifier for the target chat or username
4231
+ of the target channel (in the format ``@channelusername``).
4232
+ user_id (:obj:`int`): Unique identifier of the target user.
4233
+ timeout (:obj:`int` | :obj:`float`, optional): If this value is specified, use it as
4234
+ the read timeout from the server (instead of the one specified during creation of
4235
+ the connection pool).
4236
+ api_kwargs (:obj:`dict`, optional): Arbitrary keyword arguments to be passed to the
4237
+ Telegram API.
4238
+
4239
+ Returns:
4240
+ :obj:`bool`: On success, :obj:`True` is returned.
4241
+
4242
+ Raises:
4243
+ :class:`telegram.error.TelegramError`
4244
+ """
4245
+ data : JSONDict = {'chat_id' : chat_id , 'user_id' : user_id }
4246
+
4247
+ result = self ._post ('declineChatJoinRequest' , data , timeout = timeout , api_kwargs = api_kwargs )
4248
+
4249
+ return result # type: ignore[return-value]
4250
+
4129
4251
@log
4130
4252
def set_chat_photo (
4131
4253
self ,
@@ -5436,11 +5558,15 @@ def __hash__(self) -> int:
5436
5558
exportChatInviteLink = export_chat_invite_link
5437
5559
"""Alias for :meth:`export_chat_invite_link`"""
5438
5560
createChatInviteLink = create_chat_invite_link
5439
- """Alias for :attr :`create_chat_invite_link`"""
5561
+ """Alias for :meth :`create_chat_invite_link`"""
5440
5562
editChatInviteLink = edit_chat_invite_link
5441
- """Alias for :attr :`edit_chat_invite_link`"""
5563
+ """Alias for :meth :`edit_chat_invite_link`"""
5442
5564
revokeChatInviteLink = revoke_chat_invite_link
5443
- """Alias for :attr:`revoke_chat_invite_link`"""
5565
+ """Alias for :meth:`revoke_chat_invite_link`"""
5566
+ approveChatJoinRequest = approve_chat_join_request
5567
+ """Alias for :meth:`approve_chat_join_request`"""
5568
+ declineChatJoinRequest = decline_chat_join_request
5569
+ """Alias for :meth:`decline_chat_join_request`"""
5444
5570
setChatPhoto = set_chat_photo
5445
5571
"""Alias for :meth:`set_chat_photo`"""
5446
5572
deleteChatPhoto = delete_chat_photo
0 commit comments