|
10 | 10 | use TelegramBot\Api\Types\ArrayOfUpdates; |
11 | 11 | use TelegramBot\Api\Types\BotCommand; |
12 | 12 | use TelegramBot\Api\Types\Chat; |
| 13 | +use TelegramBot\Api\Types\ChatInviteLink; |
13 | 14 | use TelegramBot\Api\Types\ChatMember; |
14 | 15 | use TelegramBot\Api\Types\File; |
15 | 16 | use TelegramBot\Api\Types\ForceReply; |
@@ -2126,6 +2127,117 @@ public function exportChatInviteLink($chatId) |
2126 | 2127 | ]); |
2127 | 2128 | } |
2128 | 2129 |
|
| 2130 | + /** |
| 2131 | + * Use this method to create an additional invite link for a chat. The bot must be an administrator in the chat |
| 2132 | + * for this to work and must have the appropriate administrator rights. |
| 2133 | + * The link can be revoked using the method revokeChatInviteLink. |
| 2134 | + * Returns the new invite link as ChatInviteLink object. |
| 2135 | + * |
| 2136 | + * @param int|string $chatId Unique identifier for the target chat or |
| 2137 | + * username of the target channel (in the format @channelusername) |
| 2138 | + * @param string|null $name Invite link name; 0-32 characters |
| 2139 | + * @param int|null $expireDate Point in time (Unix timestamp) when the link will expire |
| 2140 | + * @param int|null $memberLimit The maximum number of users that can be members of the chat simultaneously |
| 2141 | + * after joining the chat via this invite link; 1-99999 |
| 2142 | + * @param bool|null $createsJoinRequest True, if users joining the chat via the link need to be approved by chat administrators. |
| 2143 | + * If True, member_limit can't be specified |
| 2144 | + * @return ChatInviteLink |
| 2145 | + * @throws Exception |
| 2146 | + */ |
| 2147 | + public function createChatInviteLink($chatId, $name = null, $expireDate = null, $memberLimit = null, $createsJoinRequest = null) |
| 2148 | + { |
| 2149 | + return ChatInviteLink::fromResponse($this->call('createChatInviteLink', [ |
| 2150 | + 'chat_id' => $chatId, |
| 2151 | + 'name' => $name, |
| 2152 | + 'expire_date' => $expireDate, |
| 2153 | + 'member_limit' => $memberLimit, |
| 2154 | + 'creates_join_request' => $createsJoinRequest, |
| 2155 | + ])); |
| 2156 | + } |
| 2157 | + |
| 2158 | + /** |
| 2159 | + * Use this method to edit a non-primary invite link created by the bot. |
| 2160 | + * The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. |
| 2161 | + * Returns the edited invite link as a ChatInviteLink object. |
| 2162 | + * |
| 2163 | + * @param int|string $chatId Unique identifier for the target chat or |
| 2164 | + * username of the target channel (in the format @channelusername) |
| 2165 | + * @param string $inviteLink The invite link to edit |
| 2166 | + * @param string|null $name Invite link name; 0-32 characters |
| 2167 | + * @param int|null $expireDate Point in time (Unix timestamp) when the link will expire |
| 2168 | + * @param int|null $memberLimit The maximum number of users that can be members of the chat simultaneously |
| 2169 | + * after joining the chat via this invite link; 1-99999 |
| 2170 | + * @param bool|null $createsJoinRequest True, if users joining the chat via the link need to be approved by chat administrators. |
| 2171 | + * If True, member_limit can't be specified |
| 2172 | + * @return ChatInviteLink |
| 2173 | + * @throws Exception |
| 2174 | + */ |
| 2175 | + public function editChatInviteLink($chatId, $inviteLink, $name = null, $expireDate = null, $memberLimit = null, $createsJoinRequest = null) |
| 2176 | + { |
| 2177 | + return ChatInviteLink::fromResponse($this->call('editChatInviteLink', [ |
| 2178 | + 'chat_id' => $chatId, |
| 2179 | + 'invite_link' => $inviteLink, |
| 2180 | + 'name' => $name, |
| 2181 | + 'expire_date' => $expireDate, |
| 2182 | + 'member_limit' => $memberLimit, |
| 2183 | + 'creates_join_request' => $createsJoinRequest, |
| 2184 | + ])); |
| 2185 | + } |
| 2186 | + |
| 2187 | + /** |
| 2188 | + * Use this method to revoke an invite link created by the bot. |
| 2189 | + * If the primary link is revoked, a new link is automatically generated. |
| 2190 | + * The bot must be an administrator in the chat for this to work and must have the appropriate administrator rights. |
| 2191 | + * Returns the revoked invite link as ChatInviteLink object. |
| 2192 | + * |
| 2193 | + * @param int|string $chatId Unique identifier for the target chat or |
| 2194 | + * username of the target channel (in the format @channelusername) |
| 2195 | + * @param string $inviteLink The invite link to edit |
| 2196 | + * @return ChatInviteLink |
| 2197 | + * @throws Exception |
| 2198 | + */ |
| 2199 | + public function revokeChatInviteLink($chatId, $inviteLink) |
| 2200 | + { |
| 2201 | + return ChatInviteLink::fromResponse($this->call('revokeChatInviteLink', [ |
| 2202 | + 'chat_id' => $chatId, |
| 2203 | + 'invite_link' => $inviteLink, |
| 2204 | + ])); |
| 2205 | + } |
| 2206 | + |
| 2207 | + /** |
| 2208 | + * Use this method to approve a chat join request. The bot must be an administrator in the chat for this to work and |
| 2209 | + * must have the can_invite_users administrator right. Returns True on success. |
| 2210 | + * |
| 2211 | + * @param int|string $chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
| 2212 | + * @param int $userId Unique identifier of the target user |
| 2213 | + * @return bool |
| 2214 | + * @throws Exception |
| 2215 | + */ |
| 2216 | + public function approveChatJoinRequest($chatId, $userId) |
| 2217 | + { |
| 2218 | + return $this->call('approveChatJoinRequest', [ |
| 2219 | + 'chat_id' => $chatId, |
| 2220 | + 'user_id' => $userId, |
| 2221 | + ]); |
| 2222 | + } |
| 2223 | + |
| 2224 | + /** |
| 2225 | + * Use this method to decline a chat join request. The bot must be an administrator in the chat for this to work and |
| 2226 | + * must have the can_invite_users administrator right. Returns True on success. |
| 2227 | + * |
| 2228 | + * @param int|string $chatId Unique identifier for the target chat or username of the target channel (in the format @channelusername) |
| 2229 | + * @param int $userId Unique identifier of the target user |
| 2230 | + * @return bool |
| 2231 | + * @throws Exception |
| 2232 | + */ |
| 2233 | + public function declineChatJoinRequest($chatId, $userId) |
| 2234 | + { |
| 2235 | + return $this->call('declineChatJoinRequest', [ |
| 2236 | + 'chat_id' => $chatId, |
| 2237 | + 'user_id' => $userId, |
| 2238 | + ]); |
| 2239 | + } |
| 2240 | + |
2129 | 2241 | /** |
2130 | 2242 | * Use this method to set a new profile photo for the chat. Photos can't be changed for private chats. |
2131 | 2243 | * The bot must be an administrator in the chat for this to work and must have the appropriate admin rights. |
|
0 commit comments