讨论组
可以将群组关联到频道作为讨论组,以便用户可以讨论帖子。
频道评论
boolFalse#bc799737 = Bool; boolTrue#997275b5 = Bool;channelFull#e4e0b29d flags:# can_view_participants:flags.3?true can_set_username:flags.6?true can_set_stickers:flags.7?true hidden_prehistory:flags.10?true can_set_location:flags.16?true has_scheduled:flags.19?true can_view_stats:flags.20?true blocked:flags.22?true flags2:# can_delete_channel:flags2.0?true antispam:flags2.1?true participants_hidden:flags2.2?true translations_disabled:flags2.3?true stories_pinned_available:flags2.5?true view_forum_as_messages:flags2.6?true restricted_sponsored:flags2.11?true can_view_revenue:flags2.12?true paid_media_allowed:flags2.14?true can_view_stars_revenue:flags2.15?true paid_reactions_available:flags2.16?true stargifts_available:flags2.19?true paid_messages_available:flags2.20?true id:long about:string participants_count:flags.0?int admins_count:flags.1?int kicked_count:flags.2?int banned_count:flags.2?int online_count:flags.13?int read_inbox_max_id:int read_outbox_max_id:int unread_count:int chat_photo:Photo notify_settings:PeerNotifySettings exported_invite:flags.23?ExportedChatInvite bot_info:Vector<BotInfo> migrated_from_chat_id:flags.4?long migrated_from_max_id:flags.4?int pinned_msg_id:flags.5?int stickerset:flags.8?StickerSet available_min_id:flags.9?int folder_id:flags.11?int linked_chat_id:flags.14?long location:flags.15?ChannelLocation slowmode_seconds:flags.17?int slowmode_next_send_date:flags.18?int stats_dc:flags.12?int pts:int call:flags.21?InputGroupCall ttl_period:flags.24?int pending_suggestions:flags.25?Vector<string> groupcall_default_join_as:flags.26?Peer theme_emoticon:flags.27?string requests_pending:flags.28?int recent_requesters:flags.28?Vector<long> default_send_as:flags.29?Peer available_reactions:flags.30?ChatReactions reactions_limit:flags2.13?int stories:flags2.4?PeerStories wallpaper:flags2.7?WallPaper boosts_applied:flags2.8?int boosts_unrestrict:flags2.9?int emojiset:flags2.10?StickerSet bot_verification:flags2.17?BotVerification stargifts_count:flags2.18?int send_paid_messages_stars:flags2.21?long main_tab:flags2.22?ProfileTab = ChatFull;messages.chats#64ff9fd5 chats:Vector<Chat> = messages.Chats;messageReplies#83d60fc2 flags:# comments:flags.0?true replies:int replies_pts:int recent_repliers:flags.1?Vector<Peer> channel_id:flags.0?long max_id:flags.2?int read_max_id:flags.3?int = MessageReplies;messages.discussionMessage#a6341782 flags:# messages:Vector<Message> max_id:flags.0?int read_inbox_max_id:flags.1?int read_outbox_max_id:flags.2?int unread_count:int chats:Vector<Chat> users:Vector<User> = messages.DiscussionMessage;---functions---channels.setDiscussionGroup#40582bb2 broadcast:InputChannel group:InputChannel = Bool; channels.getGroupsForDiscussion#f5dad378 = messages.Chats;messages.getDiscussionMessage#446972fd peer:InputPeer msg_id:int = messages.DiscussionMessage;
可以使用channels.setDiscussionGroup将讨论组关联到频道。
在客户端中,可以通过点击频道的讨论按钮或访问特定帖子的评论区来访问讨论组;讨论组 ID 也存在于channelFulllinked_chat_id构造函数的字段中。
发送到该频道的所有消息也将转发到关联的群组(发送方对等节点from_id与关联频道的对等节点相同);这些消息也将自动置顶在群组中。
频道帖子评论区实际上就是链接讨论组内自动转发的频道帖子消息的讨论串
。
因此,要禁用特定帖子的评论区,只需将自动转发的频道帖子消息从讨论组中移除即可。
messageReplies构造函数会将频道帖子附加到原始频道中,其中包含有关评论部分的信息,具体如下:
- replies.channel_id将包含链接讨论超级组的 ID
- replies.recent_repliers将包含特定主题下最后几条评论的信息,并在客户端预览中显示评论者头像的简短列表。
- replies.replies将显示评论区回复的总数。
- replies.max_id可能包含评论区最新消息的 ID(如有)。
- replies.replies_pts可能包含引发评论区的自动转发频道消息的 PTS。
对于发起讨论的所有群组消息,自动转发到讨论组的消息中也会包含与主题的通常标志相同的messageReplies构造函数(即不带, )。channel_idrecent_replies
使用messages.getDiscussionMessage获取链接讨论超级组中自动转发频道消息的消息线程的初始消息。
消息按时间倒序返回(即按消息 ID 降序排列);因此,该方法返回的最后一条消息将是启动评论部分的自动转发频道消息。
回复
messageFwdHeader#4e4df4bb flags:# imported:flags.7?true saved_out:flags.11?true from_id:flags.0?Peer from_name:flags.5?string date:int channel_post:flags.2?int post_author:flags.3?string saved_from_peer:flags.4?Peer saved_from_msg_id:flags.4?int saved_from_id:flags.8?Peer saved_from_name:flags.9?string saved_date:flags.10?int psa_type:flags.6?string = MessageFwdHeader;messageReplyHeader#6917560b flags:# reply_to_scheduled:flags.2?true forum_topic:flags.3?true quote:flags.9?true reply_to_msg_id:flags.4?int reply_to_peer_id:flags.0?Peer reply_from:flags.5?MessageFwdHeader reply_media:flags.8?MessageMedia reply_to_top_id:flags.1?int quote_text:flags.6?string quote_entities:flags.7?Vector<MessageEntity> quote_offset:flags.10?int todo_item_id:flags.11?int = MessageReplyHeader;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;updateNewMessage#1f2b0afd message:Message pts:int pts_count:int = Update; updateNewChannelMessage#62ba04d9 message:Message pts:int pts_count:int = Update;---functions---contacts.blockFromReplies#29a8962c flags:# delete_message:flags.0?true delete_history:flags.1?true report_spam:flags.2?true msg_id:int = Updates;contacts.resolveUsername#725afbbc flags:# username:string referer:flags.0?string = contacts.ResolvedPeer;
由于用户无需加入实际的讨论组即可在频道帖子中发表评论,因此必须有一种方法让他们能够收到评论回复的通知。
为此,我们提供了一个特殊的用户名。其在主接口和测试接口上的 ID 可以在tdlib 源代码@replies中找到。
当有人在频道帖子评论区回复我们的消息,且该用户未订阅该讨论组时,客户端将收到两条更新信息:
-
来自讨论组本身的 updateNewChannelMessage,其结构与来自已订阅组的任何其他更新完全相同,内容如下:
- id设置为回复的 ID
- from_id设置为回复我们的对等方
- peer_id设置为讨论组的同级成员
- reply_to.reply_to_msg_id设置为我们消息的 ID
- reply_to.reply_to_top_id设置为线程 ID。
-
更新新消息
- id设置为用户的通用 ID 序列
- from_id设置为同级@replies
- peer_id设置为我们自己的同伴
- fwd_from.saved_from_msg_id设置为回复的 ID
- fwd_from.from_id设置为回复我们的对等方
- reply_to.reply_to_peer_id设置为讨论组的同级成员
- reply_to.reply_to_msg_id设置为我们消息的 ID
- reply_to.reply_to_top_id设置为线程 ID
客户端应将来自该群组的消息显示@replies为只读超级群组,每条回复应显示为回复作者的单独消息,并像频道评论一样提供“在聊天中查看”按钮。
contacts.blockFromReplies可用于停止接收来自特定用户的线程回复通知@replies。
链接讨论组
要获取频道管理员可以关联到频道的已管理超级群组列表,请使用`channels.getGroupsForDiscussion`。
返回的基本群聊必须先升级为超级群组,才能将其设置为讨论组。
在将超级群组链接到频道之前,还必须使用`channels.togglePreHistoryHidden`启用对超级群组旧消息的访问权限。
要将返回的超级组设置为讨论组,请使用channels.setDiscussionGroup。
模式:
boolFalse#bc799737 = Bool; boolTrue#997275b5 = Bool;messages.chats#64ff9fd5 chats:Vector<Chat> = messages.Chats;---functions---channels.setDiscussionGroup#40582bb2 broadcast:InputChannel group:InputChannel = Bool; channels.getGroupsForDiscussion#f5dad378 = messages.Chats;channels.togglePreHistoryHidden#eabbb94c channel:InputChannel enabled:Bool = Updates;
要求用户加入该组
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;---functions---channels.toggleJoinToSend#e4cb9580 channel:InputChannel enabled:Bool = Updates;
管理员可以使用channels.toggleJoinToSend强制用户加入讨论组后才能发表评论。
该channel.join_to_send标志将被相应地设置,所有非成员尝试向该组发送消息的行为都将返回CHAT_GUEST_SEND_FORBIDDENRPC 错误。