邀请链接和加入请求

电报聊天和频道可以有公开用户名或私人邀请链接:私人邀请链接可以进一步增强每个用户的加入请求。

公开用户名

contacts.resolvedPeer#7f077ad9 peer:Peer chats:Vector<Chat> users:Vector<User> = contacts.ResolvedPeer;---functions---contacts.resolveUsername#725afbbc flags:# username:string referer:flags.0?string = contacts.ResolvedPeer; channels.joinChannel#24b524c5 channel:InputChannel = Updates;channels.checkUsername#10e6bd2c channel:InputChannel username:string = Bool; channels.updateUsername#3514b3de channel:InputChannel username:string = Bool;

只有超级组和频道才能拥有公共用户名:普通组必须先迁移到超级组才能分配用户名,请参阅迁移文档»了解更多信息。

channels.updateUsername可用于直接分配或更改超级组或频道的公共用户名。在分配用户名之前,
您可以使用channels.checkUsername来确保指定的用户名有效且可用。

channels.joinChannel可以使用contacts.resolveUsername获取的对等信息加入超级组或频道。

邀请链接

chatInviteExported#a22cbd96 flags:# revoked:flags.0?true permanent:flags.5?true request_needed:flags.6?true link:string admin_id:long date:int start_date:flags.4?int expire_date:flags.1?int usage_limit:flags.2?int usage:flags.3?int requested:flags.7?int subscription_expired:flags.10?int title:flags.8?string subscription_pricing:flags.9?StarsSubscriptionPricing = ExportedChatInvite;messages.exportedChatInvites#bdc62dcc count:int invites:Vector<ExportedChatInvite> users:Vector<User> = messages.ExportedChatInvites;messages.exportedChatInvite#1871be50 invite:ExportedChatInvite users:Vector<User> = messages.ExportedChatInvite; messages.exportedChatInviteReplaced#222600ef invite:ExportedChatInvite new_invite:ExportedChatInvite users:Vector<User> = messages.ExportedChatInvite;chatInviteImporter#8c5adfd9 flags:# requested:flags.0?true via_chatlist:flags.3?true user_id:long date:int about:flags.2?string approved_by:flags.1?long = ChatInviteImporter;messages.chatInviteImporters#81b6b00a count:int importers:Vector<ChatInviteImporter> users:Vector<User> = messages.ChatInviteImporters;chatAdminWithInvites#f2ecef23 admin_id:long invites_count:int revoked_invites_count:int = ChatAdminWithInvites;messages.chatAdminsWithInvites#b69b72d7 admins:Vector<ChatAdminWithInvites> users:Vector<User> = messages.ChatAdminsWithInvites;chatInviteAlready#5a686d7c chat:Chat = ChatInvite; chatInvite#5c9d3702 flags:# channel:flags.0?true broadcast:flags.1?true public:flags.2?true megagroup:flags.3?true request_needed:flags.6?true verified:flags.7?true scam:flags.8?true fake:flags.9?true can_refulfill_subscription:flags.11?true title:string about:flags.5?string photo:Photo participants_count:int participants:flags.4?Vector<User> color:int subscription_pricing:flags.10?StarsSubscriptionPricing subscription_form_id:flags.12?long bot_verification:flags.13?BotVerification = ChatInvite; chatInvitePeek#61695cb0 chat:Chat expires:int = ChatInvite;---functions---messages.exportChatInvite#a455de90 flags:# legacy_revoke_permanent:flags.2?true request_needed:flags.3?true peer:InputPeer expire_date:flags.0?int usage_limit:flags.1?int title:flags.4?string subscription_pricing:flags.5?StarsSubscriptionPricing = ExportedChatInvite;messages.getExportedChatInvites#a2b5a3f6 flags:# revoked:flags.3?true peer:InputPeer admin_id:InputUser offset_date:flags.2?int offset_link:flags.2?string limit:int = messages.ExportedChatInvites; messages.getExportedChatInvite#73746f5c peer:InputPeer link:string = messages.ExportedChatInvite;messages.editExportedChatInvite#bdca2f75 flags:# revoked:flags.2?true peer:InputPeer link:string expire_date:flags.0?int usage_limit:flags.1?int request_needed:flags.3?Bool title:flags.4?string = messages.ExportedChatInvite;messages.deleteRevokedExportedChatInvites#56987bd5 peer:InputPeer admin_id:InputUser = Bool; messages.deleteExportedChatInvite#d464a42b peer:InputPeer link:string = Bool;messages.getAdminsWithInvites#3920e6ef peer:InputPeer = messages.ChatAdminsWithInvites; messages.getChatInviteImporters#df04dd4e flags:# requested:flags.0?true subscription_expired:flags.3?true peer:InputPeer link:flags.1?string q:flags.2?string offset_date:int offset_user:InputUser limit:int = messages.ChatInviteImporters;messages.checkChatInvite#3eadb1bb hash:string = ChatInvite; messages.importChatInvite#6c50051c hash:string = Updates;

私人邀请链接可以设置过期日期、使用限制,甚至可以设置为仅允许用户在管理员明确批准后才能加入频道、超级群组或群组:请参阅加入请求»了解更多信息。

邀请链接符合以下正则表达式:@(?:t|telegram)\.(?:me|dog)/(joinchat/|\+)?([\w-]+)@i。
第一个匹配的群组可以传递给`messages.checkChatInvite`hash的参数以获取聊天信息,并传递给 `messages.importChatInvite`以加入聊天。`messages.checkChatInvite`可能仅对超级群组和频道返回`chatInvitePeek`,在这种情况下,用户可以直接使用`updates`、`messages.getHistory`和`channels.getMessages`获取聊天消息,直到 `unixtime` 字段指示的时间为止。
expires

新建的群组、超级群组和频道都已默认生成邀请链接。
要生成新的邀请链接,请使用`messages.exportChatInvite`。
要获取现有聊天邀请的信息(可以选择仅筛选由特定管理员创建的链接),请使用`messages.getExportedChatInvites`。`messages.getExportedChatInvite`也可用于获取特定邀请链接的信息。

`messages.editExportedChatInvite`用于编辑或撤销现有的邀请链接:撤销的链接将无法被用户用于加入群组,但仍可通过设置相应标志的 `messages.getExportedChatInvites` 获取已撤销链接的信息。使用revoked`
messages.deleteExportedChatInvite`可永久删除邀请链接,使用`messages.deleteRevokedExportedChatInvites`可永久删除已撤销的邀请链接。

messages.getChatInviteImporters可用于获取有关使用特定邀请链接加入的用户的信息。

可以使用messages.getAdminsWithInvites获取有关给定管理员生成的邀请链接数量的一些基本统计信息。

付费邀请链接

频道管理员现在可以创建特殊的邀请链接,允许用户通过每月支付 Telegram Stars 来加入频道。

使用付费邀请链接订阅频道,即可将 Telegram 星星转入该频道的余额。

请点击这里»查看完整流程的更多信息。

加入请求

channel#fe685355 flags:# creator:flags.0?true left:flags.2?true broadcast:flags.5?true verified:flags.7?true megagroup:flags.8?true restricted:flags.9?true signatures:flags.11?true min:flags.12?true scam:flags.19?true has_link:flags.20?true has_geo:flags.21?true slowmode_enabled:flags.22?true call_active:flags.23?true call_not_empty:flags.24?true fake:flags.25?true gigagroup:flags.26?true noforwards:flags.27?true join_to_send:flags.28?true join_request:flags.29?true forum:flags.30?true flags2:# stories_hidden:flags2.1?true stories_hidden_min:flags2.2?true stories_unavailable:flags2.3?true signature_profiles:flags2.12?true autotranslation:flags2.15?true broadcast_messages_allowed:flags2.16?true monoforum:flags2.17?true forum_tabs:flags2.19?true id:long access_hash:flags.13?long title:string username:flags.6?string photo:ChatPhoto date:int restriction_reason:flags.9?Vector<RestrictionReason> admin_rights:flags.14?ChatAdminRights banned_rights:flags.15?ChatBannedRights default_banned_rights:flags.18?ChatBannedRights participants_count:flags.17?int usernames:flags2.0?Vector<Username> stories_max_id:flags2.4?int color:flags2.7?PeerColor profile_color:flags2.8?PeerColor emoji_status:flags2.9?EmojiStatus level:flags2.10?int subscription_until_date:flags2.11?int bot_verification_icon:flags2.13?long send_paid_messages_stars:flags2.14?long linked_monoforum_id:flags2.18?long = Chat;chatInvite#5c9d3702 flags:# channel:flags.0?true broadcast:flags.1?true public:flags.2?true megagroup:flags.3?true request_needed:flags.6?true verified:flags.7?true scam:flags.8?true fake:flags.9?true can_refulfill_subscription:flags.11?true title:string about:flags.5?string photo:Photo participants_count:int participants:flags.4?Vector<User> color:int subscription_pricing:flags.10?StarsSubscriptionPricing subscription_form_id:flags.12?long bot_verification:flags.13?BotVerification = ChatInvite;updatePendingJoinRequests#7063c3db peer:Peer requests_pending:int recent_requesters:Vector<long> = Update; updateBotChatInviteRequester#11dfa986 peer:Peer date:int user_id:long about:string invite:ExportedChatInvite qts:int = Update;messages.chatInviteImporters#81b6b00a count:int importers:Vector<ChatInviteImporter> users:Vector<User> = messages.ChatInviteImporters;peerSettings#f47741f7 flags:# report_spam:flags.0?true add_contact:flags.1?true block_contact:flags.2?true share_contact:flags.3?true need_contacts_exception:flags.4?true report_geo:flags.5?true autoarchived:flags.7?true invite_members:flags.8?true request_chat_broadcast:flags.10?true business_bot_paused:flags.11?true business_bot_can_reply:flags.12?true geo_distance:flags.6?int request_chat_title:flags.9?string request_chat_date:flags.9?int business_bot_id:flags.13?long business_bot_manage_url:flags.13?string charge_paid_message_stars:flags.14?long registration_month:flags.15?string phone_country:flags.16?string name_change_date:flags.17?int photo_change_date:flags.18?int = PeerSettings;messageActionChatJoinedByRequest#ebbca3cb = MessageAction;channelAdminLogEventActionParticipantJoinByRequest#afb6144a invite:ExportedChatInvite approved_by:long = ChannelAdminLogEventAction;---functions---messages.checkChatInvite#3eadb1bb hash:string = ChatInvite; messages.importChatInvite#6c50051c hash:string = Updates;messages.getChatInviteImporters#df04dd4e flags:# requested:flags.0?true subscription_expired:flags.3?true peer:InputPeer link:flags.1?string q:flags.2?string offset_date:int offset_user:InputUser limit:int = messages.ChatInviteImporters;messages.hideChatJoinRequest#7fe7e815 flags:# approved:flags.0?true peer:InputPeer user_id:InputUser = Updates; messages.hideAllChatJoinRequests#e085f4ea flags:# approved:flags.0?true peer:InputPeer link:flags.1?string = Updates;channels.toggleJoinRequest#4c2985b6 channel:InputChannel enabled:Bool = Updates;

如果在生成或编辑邀请链接request_needed时设置了该标志,或者使用channels.toggleJoinRequest切换了相应的选项,则使用messages.importChatInvite导入邀请链接的用户将收到RPC 错误,表明已成功向聊天管理员发送加入请求。INVITE_REQUEST_SENT

相关超群信息也会channel.join_request相应地设置标记。

机器人管理员将收到每个单独的加入请求的updateBotChatInviteRequester
更新。 用户管理员将收到updatePendingJoinRequests更新,并应调用messages.getChatInviteImporters并requested设置相应标志,以获取等待加入群组的用户列表。

管理员可以使用messages.hideChatJoinRequest来批准或拒绝单个加入请求,并使用messages.hideAllChatJoinRequests来批量批准或拒绝多个加入请求。

管理员还可以选择在允许用户加入群组之前向其发送消息:在这种情况下,用户端的图形客户端应在与管理员的聊天对话框栏上显示一条消息,表明该聊天是由用户最近请求加入的聊天/频道的管理员发起的,有关更多信息, 请参阅操作栏文档» 。

直接邀请

missingInvitee#628c9224 flags:# premium_would_allow_invite:flags.0?true premium_required_for_pm:flags.1?true user_id:long = MissingInvitee;messages.invitedUsers#7f5defa6 updates:Updates missing_invitees:Vector<MissingInvitee> = messages.InvitedUsers;---functions---messages.addChatUser#cbc6d107 chat_id:long user_id:InputUser fwd_limit:int = messages.InvitedUsers; messages.createChat#92ceddd4 flags:# users:Vector<InputUser> title:string ttl_period:flags.0?int = messages.InvitedUsers;channels.inviteToChannel#c9e33d54 channel:InputChannel users:Vector<InputUser> = messages.InvitedUsers;

用户也可以在创建群组和频道时(通过messages.createChat创建基本群组)或之后(通过messages.addChatUser创建基本群组,通过channels.inviteToChannel 创建超级群组和频道)直接被邀请加入。

这些方法将返回messages.invitedUsers构造函数,其中包含有关成功邀请用户的更新列表(以及最终有关已创建组的信息),以及missingInvitee列表,其中包含由于某些原因无法邀请的用户列表。

具体来说: