年龄验证
某些法律法规要求查看受限内容时进行年龄验证:Telegram 通过一个特殊机器人的主小程序来实现这一点。
restrictionReason#d072acb4 platform:string reason:string text:string = RestrictionReason;user#20b1422 flags:# self:flags.10?true contact:flags.11?true mutual_contact:flags.12?true deleted:flags.13?true bot:flags.14?true bot_chat_history:flags.15?true bot_nochats:flags.16?true verified:flags.17?true restricted:flags.18?true min:flags.20?true bot_inline_geo:flags.21?true support:flags.23?true scam:flags.24?true apply_min_photo:flags.25?true fake:flags.26?true bot_attach_menu:flags.27?true premium:flags.28?true attach_menu_enabled:flags.29?true flags2:# bot_can_edit:flags2.1?true close_friend:flags2.2?true stories_hidden:flags2.3?true stories_unavailable:flags2.4?true contact_require_premium:flags2.10?true bot_business:flags2.11?true bot_has_main_app:flags2.13?true id:long access_hash:flags.0?long first_name:flags.1?string last_name:flags.2?string username:flags.3?string phone:flags.4?string photo:flags.5?UserProfilePhoto status:flags.6?UserStatus bot_info_version:flags.14?int restriction_reason:flags.18?Vector<RestrictionReason> bot_inline_placeholder:flags.19?string lang_code:flags.22?string emoji_status:flags.30?EmojiStatus usernames:flags2.0?Vector<Username> stories_max_id:flags2.5?int color:flags2.8?PeerColor profile_color:flags2.9?PeerColor bot_active_users:flags2.12?int bot_verification_icon:flags2.14?long send_paid_messages_stars:flags2.15?long = User;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;message#9815cec8 flags:# out:flags.1?true mentioned:flags.4?true media_unread:flags.5?true silent:flags.13?true post:flags.14?true from_scheduled:flags.18?true legacy:flags.19?true edit_hide:flags.21?true pinned:flags.24?true noforwards:flags.26?true invert_media:flags.27?true flags2:# offline:flags2.1?true video_processing_pending:flags2.4?true paid_suggested_post_stars:flags2.8?true paid_suggested_post_ton:flags2.9?true id:int from_id:flags.8?Peer from_boosts_applied:flags.29?int peer_id:Peer saved_peer_id:flags.28?Peer fwd_from:flags.2?MessageFwdHeader via_bot_id:flags.11?long via_business_bot_id:flags2.0?long reply_to:flags.3?MessageReplyHeader date:int message:string media:flags.9?MessageMedia reply_markup:flags.6?ReplyMarkup entities:flags.7?Vector<MessageEntity> views:flags.10?int forwards:flags.10?int replies:flags.23?MessageReplies edit_date:flags.15?int post_author:flags.16?string grouped_id:flags.17?long reactions:flags.20?MessageReactions restriction_reason:flags.22?Vector<RestrictionReason> ttl_period:flags.25?int quick_reply_shortcut_id:flags.30?int effect:flags2.2?long factcheck:flags2.3?FactCheck report_delivery_until_date:flags2.5?int paid_message_stars:flags2.6?long suggested_post:flags2.7?SuggestedPost = Message;
通过各种平台和原因,用户、聊天、频道和个人消息的访问权限可能会受到限制restriction_reason。
要检查是否有任何限制原因适用于我们,请遍历字段中的restrictionReasonrestriction_reason对象,仅保留满足以下条件的原因:
- restrictionReason等于platformall
-
对于restrictionReason中指定的所有平台(platform其中包含一个或多个平台的连接列表,以逗号分隔-):
- 至少有一个与当前平台匹配(根据当前平台硬编码在客户端中,例如ios,,,等)android。wp
- 至少有一个平台与restriction_add_platforms 动态配置参数中指定的平台匹配 »
- restrictionReasonreason不包含在ignore_restriction_reasons 动态配置参数指定的原因列表中。
reason如果筛选后可用的 s中至少有一个不等于,则必须完全限制对内容的 访问,并显示restrictionReasonsensitive中指定的错误。text
如果 onlyreason等于sensitive,并且need_age_video_verification »客户端配置键未设置或等于false,则年龄验证将被禁用,并且可以访问内容,前提是内容隐藏在18+剧透后面。
如果 onlyreason等于sensitive,并且need_age_video_verification »客户端配置键等于true,则只能在点击剧透内容后进行年龄验证才能访问该内容18+。
以下客户端配置参数»用于实现年龄验证:
- need_age_video_verification »- 指定当前司法管辖区是否需要年龄验证;false也可以指定用户是否已成功通过年龄验证。
- verify_age_country »- 法律要求进行年龄验证的国家或地区的唯一名称。
- verify_age_min »- 包含查看sensitive内容所需的最低年龄
-
verify_age_bot_username »- 包含用于进行年龄验证的机器人的用户名,必须打开该机器人的主小程序才能进行年龄验证。
注意:仅在年龄验证期间,年龄验证小程序的所有权限请求(摄像头、麦克风等)都应无条件允许,无需用户交互(操作系统要求的情况除外);视频和音频播放也应无条件允许,无需用户交互。
验证成功或失败后,小程序将发出一个web_app_verify_age事件,其中包含检测到的年龄信息。