机器人故事

Telegram 用户和频道可以通过 API轻松发布和查看机器人故事。

发布故事

模式:

inputPeerSelf#7da07ec9 = InputPeer; inputPeerChannel#27bcbbfc channel_id:long access_hash:long = InputPeer;boolFalse#bc799737 = Bool; boolTrue#997275b5 = Bool;updateStory#75b3b798 peer:Peer story:StoryItem = Update;updateStoryID#1bf335b9 id:int random_id:long = Update;---functions---stories.canSendStory#30eb63f0 peer:InputPeer = stories.CanSendStoryCount; stories.sendStory#737fc2ec flags:# pinned:flags.2?true noforwards:flags.4?true fwd_modified:flags.7?true peer:InputPeer media:InputMedia media_areas:flags.5?Vector<MediaArea> caption:flags.0?string entities:flags.1?Vector<MessageEntity> privacy_rules:Vector<InputPrivacyRule> random_id:long period:flags.3?int fwd_from_id:flags.6?InputPeer fwd_from_story:flags.6?int albums:flags.8?Vector<int> = Updates;stories.getChatsToSend#a56a8b60 = messages.Chats;

在发布故事之前,客户端应调用stories.canSendStory,以确保他们可以将故事发送到指定的对象peer(可以是inputPeerSelf以普通用户身份发送故事,也可以是inputPeerChannel以频道或超级群组身份发送故事)。

使用stories.getChatsToSend获取用户可以发布故事的频道/超级群组列表;上传故事前仍需使用stories.canSendStory确保未达到其他限制,详情请参阅主文档 »。请注意,要获得以频道/超级群组身份发布故事的权限,必须先对其进行推广,更多信息 请参见此处 » 。

仅当满足以下条件时, `stories.canSendStory`才会返回一个`stories.canSendStoryCount`,其值为可用活动故事槽的数量(等于story_expiring_limit_*客户端配置参数的值减去当前活动故事的数量):

客户端在检查故事是否可以发布后,可以调用stories.sendStory来上传故事。
请注意,如果在调用stories.canSendStory和stories.sendStory之间任何条件发生变化(例如,用户从其他客户端上传故事,达到每周限制),则stories.sendStory会发出与stories.canSendStory相同的错误。

stories.sendStory的参数在方法页面 »中有完整描述,以下是一些最重要的参数:

故事成功上传后,将返回updateStoryIDid,指示分配给该故事的故事 ID (就像消息一样,random_id指示random_id传递给stories.sendStory的 ID :这样,您可以id通过检查哪个stories.sendStory调用返回了该 ID来判断哪个故事被分配了特定的 IDrandom_id)。

此外,发布故事会向我们以及我们的订阅者/联系人发出updateStory 更新(即使他们隐藏了我们的故事)。

此外,如果故事发布者在故事标题中提及我们,则还会自动生成一条 包含messageMediaStory的消息,其中包含来自故事发布者的标志。via_mention

小程序还可以使用 web_app_share_to_story 事件请求在用户个人资料中分享故事»。

编辑故事

inputFile#f52ff27f id:long parts:int name:string md5_checksum:string = InputFile; inputFileBig#fa4f0bb5 id:long parts:int name:string = InputFile; inputFileStoryDocument#62dc8b48 id:InputDocument = InputFile;inputMediaUploadedPhoto#1e287d04 flags:# spoiler:flags.2?true file:InputFile stickers:flags.0?Vector<InputDocument> ttl_seconds:flags.1?int = InputMedia; inputMediaUploadedDocument#37c9330 flags:# nosound_video:flags.3?true force_file:flags.4?true spoiler:flags.5?true file:InputFile thumb:flags.2?InputFile mime_type:string attributes:Vector<DocumentAttribute> stickers:flags.0?Vector<InputDocument> video_cover:flags.6?InputPhoto video_timestamp:flags.7?int ttl_seconds:flags.1?int = InputMedia;inputMediaPhoto#b3ba0635 flags:# spoiler:flags.1?true id:InputPhoto ttl_seconds:flags.0?int = InputMedia; inputMediaDocument#a8763ab5 flags:# spoiler:flags.2?true id:InputDocument video_cover:flags.3?InputPhoto video_timestamp:flags.4?int ttl_seconds:flags.0?int query:flags.1?string = InputMedia;---functions---stories.editStory#b583ba46 flags:# peer:InputPeer id:int media:flags.0?InputMedia media_areas:flags.3?Vector<MediaArea> caption:flags.1?string entities:flags.1?Vector<MessageEntity> privacy_rules:flags.2?Vector<InputPrivacyRule> = Updates;

也可以使用stories.editStory编辑故事。

注意:通常情况下,如果只是编辑文件的文档属性(例如通过documentAttributeFilename编辑文件名,通过documentAttributeVideo编辑视频缩略图的时间戳preload_prefix_size等),而不编辑媒体本身,则需要完整下载并重新上传底层媒体,因为这些属性已嵌入媒体中,无法通过inputMediaDocument进行修改(不像其他一些属性,例如,可以通过在inputMediaDocumentspoiler中传递旧媒体并调整inputMediaDocument的相应标志来编辑这些属性,而无需重新上传)。id

但是,对于视频故事,如果只编辑documentAttributeVideo属性,就可以避免完整下载+重新上传video_start_ts:在这种情况下,应该使用inputMediaUploadedDocumentfile,将其传递给inputFileStoryDocument ,并将旧的故事媒体(而不是重新上传的inputFile )传递给inputFileStoryDocument,并将剩余的字段和属性填充为与之前完全相同的值,但documentAttributeVideo属性除外,该属性应包含新值。video_start_ts

置顶或存档的故事

stories.stories#63c3dd0a flags:# count:int stories:Vector<StoryItem> pinned_to_top:flags.0?Vector<int> chats:Vector<Chat> users:Vector<User> = stories.Stories;---functions---stories.togglePinned#9a75a1ef peer:InputPeer id:Vector<int> pinned:Bool = Vector<int>; stories.togglePinnedToTop#b297e9b peer:InputPeer id:Vector<int> = Bool;stories.getStoriesArchive#b4352016 peer:InputPeer offset_id:int limit:int = stories.Stories;stories.getPinnedStories#5821a5dc peer:InputPeer offset_id:int limit:int = stories.Stories;

活跃故事过期后,会自动添加到故事存档中:故事存档中的故事只有发布者或具有edit_stories管理员权限的频道/超级群组管理员才能看到。

使用stories.getStoriesArchive从故事存档中获取故事。

存档的故事可以固定在个人资料中,用户可以通过stories.getPinnedStories获取这些故事,前提是他们明确打开了您的个人资料:使用stories.togglePinned将一个或多个故事固定或取消固定到您的个人资料中。

如果在发布故事时pinned设置了标记,则故事过期后可能会自动置顶。

此外,还可以使用stories.togglePinnedToTop将置顶到个人资料页面顶部的故事置顶;置顶到个人资料页面顶部的故事(最多stories_pinned_to_top_count_max数量)会在打开个人资料页面时优先显示。使用stories.getPinnedStories时,置顶到个人资料页面顶部的故事会优先返回,并且它们的 ID 也会包含在stories.stories中。
offset_id=0pinned_to_top

删除故事

---functions---stories.deleteStories#ae59db5f peer:InputPeer id:Vector<int> = Vector<int>;
使用stories.deleteStories方法,通过传入的 ID 删除一个或多个活跃的、置顶的或已存档的故事id。

阻止用户查看你的故事

您可以将用户添加到故事屏蔽列表,从而阻止他们查看您的所有故事»。

故事专辑

storyAlbum#9325705a flags:# album_id:int title:string icon_photo:flags.0?Photo icon_video:flags.1?Document = StoryAlbum;stories.albumsNotModified#564edaeb = stories.Albums; stories.albums#c3987a3a hash:long albums:Vector<StoryAlbum> = stories.Albums;---functions---stories.createAlbum#a36396e5 peer:InputPeer title:string stories:Vector<int> = StoryAlbum; stories.getAlbums#25b3eac7 peer:InputPeer hash:long = stories.Albums; stories.updateAlbum#5e5259b6 flags:# peer:InputPeer album_id:int title:flags.0?string delete_stories:flags.1?Vector<int> add_stories:flags.2?Vector<int> order:flags.3?Vector<int> = StoryAlbum; stories.reorderAlbums#8535fbd9 peer:InputPeer order:Vector<int> = Bool; stories.deleteAlbum#8d3456d0 peer:InputPeer album_id:int = Bool;stories.getAlbumStories#ac806d61 peer:InputPeer album_id:int offset:int limit:int = stories.Stories;

故事可以整理成册。

使用stories.createAlbum创建故事专辑。

使用stories.getAlbums获取用户拥有的所有故事专辑。

使用stories.getAlbumStories获取添加到专辑中的故事。

使用stories.sendStory的albums参数,将新发布的故事添加到一个或多个相册中。

使用stories.updateAlbum可以重命名相册,或者在相册中添加、删除和重新排序故事。

使用stories.reorderAlbums重新排列个人资料中的专辑。

使用stories.deleteAlbum删除相册。

一个个人资料最多可以包含stories_albums_limit »个专辑,每个专辑最多可以包含stories_album_stories_limit个故事。

故事专辑深度链接 »可用于分享专辑。

观看故事

storyItem#edf164f1 flags:# pinned:flags.5?true public:flags.7?true close_friends:flags.8?true min:flags.9?true noforwards:flags.10?true edited:flags.11?true contacts:flags.12?true selected_contacts:flags.13?true out:flags.16?true id:int date:int from_id:flags.18?Peer fwd_from:flags.17?StoryFwdHeader expire_date:int caption:flags.0?string entities:flags.1?Vector<MessageEntity> media:MessageMedia media_areas:flags.14?Vector<MediaArea> privacy:flags.2?Vector<PrivacyRule> views:flags.3?StoryViews sent_reaction:flags.15?Reaction albums:flags.19?Vector<int> = StoryItem; storyItemSkipped#ffadc913 flags:# close_friends:flags.8?true id:int date:int expire_date:int = StoryItem; storyItemDeleted#51e6ee4f id:int = StoryItem;peerStories#9a35e999 flags:# peer:Peer max_read_id:flags.0?int stories:Vector<StoryItem> = PeerStories;storiesStealthMode#712e27fd flags:# active_until_date:flags.0?int cooldown_until_date:flags.1?int = StoriesStealthMode;stories.allStories#6efc5e81 flags:# has_more:flags.0?true count:int state:string peer_stories:Vector<PeerStories> chats:Vector<Chat> users:Vector<User> stealth_mode:StoriesStealthMode = stories.AllStories; stories.allStoriesNotModified#1158fe3e flags:# state:string stealth_mode:StoriesStealthMode = stories.AllStories;stories.peerStories#cae68768 stories:PeerStories chats:Vector<Chat> users:Vector<User> = stories.PeerStories;updateReadStories#f74e932b peer:Peer max_id:int = Update;---functions---stories.getAllStories#eeb0d625 flags:# next:flags.1?true hidden:flags.2?true state:flags.0?string = stories.AllStories;stories.getStoriesByID#5774ca74 peer:InputPeer id:Vector<int> = stories.Stories; stories.getPeerStories#2c4ada50 peer:InputPeer = stories.PeerStories;stories.readStories#a556dac8 peer:InputPeer max_id:int = Vector<int>; stories.incrementStoryViews#b2028afb peer:InputPeer id:Vector<int> = Bool;stories.getAllReadPeerStories#9b5ae7f9 = Updates; stories.getPeerMaxIDs#535983c3 id:Vector<InputPeer> = Vector<int>;

联系人、订阅频道/超级群组以及更新日志用户的活跃故事应显示在主屏幕的操作栏中。
使用stories.getAllStories获取所有活跃故事的完整列表。

hidden(可选)可以设置该标志,以便获取隐藏的故事并在存档选项卡中显示,而不是在主故事列表中显示。

使用此方法进行分页与通常情况略有不同:state使用字符串来维护分页状态。

获取完整的故事列表后,可以使用存储的数据调用`stories.allStories` ,state而无需设置next标志来检查活动故事列表的更新:如果自上次调用以来没有发生任何更改,则返回`stories.allStoriesNotModified` ;否则,返回`stories.allStories`(可能需要如上所述的进一步分页)。
请注意,目前更改仅定义为向故事列表添加或删除(例如,将其移动到隐藏列表或反之亦然),而不是发布新故事;这些更改将作为简单的`updateStories`更新接收。

活跃故事列表的更改包含在stories.allStories字段中:peer_stories此字段包含一个peerStories构造函数向量,每个 peer 对应一个构造函数,其中包含 peer ID、阅读量最高的故事 ID(如果有)以及StoryItem构造函数列表,类型为:

也可以使用stories.getPeerStories来获取特定对等节点的完整活跃故事列表。

使用`stories.readStories`方法可以将指定 ID 之前的所有故事标记为已读(针对特定对等节点):如果某个更新的 ID 被标记为已读,此方法会向所有已登录会话发送`updateReadStories`更新。首次登录时,可以
使用`stories.getAllReadPeerStories`方法获取所有对等节点的最新已读故事 ID,该方法会返回一个`updateReadStories`更新列表:登录后无需再次调用此方法,因为对最新已读故事 ID 的更新将通过`updateReadStories`更新发送,并使用常规的更新方法。

使用stories.incrementStoryViews可以实际增加用户已查看的故事的浏览计数器(一次最多传递 200 个故事 ID)。

隐藏其他用户的故事

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;---functions---stories.togglePeerStoriesHidden#bd0415c4 peer:InputPeer hidden:Bool = Bool;stories.toggleAllStoriesHidden#7c2557c4 hidden:Bool = Bool;

使用`stories.togglePeerStoriesHidden`可以隐藏特定用户的活动故事,防止它们显示在主屏幕的操作栏上。
当用户的故事被标记为隐藏时,相关用户的stories_hidden构造函数会设置相应的标志。只有在打开归档文件夹时,通过在调用`stories.getAllStories`时设置该标志,这些故事才会显示在操作栏上。更多信息请参见此处。hidden

请注意,存档文件夹是用于存档聊天记录的对等文件夹:隐藏的故事之所以显示在那里,纯粹是因为 UI 实现细节,而不是因为它们实际上被添加到存档对等文件夹 »或故事存档 » 中,这两者是不同的。

分享故事

inputMediaStory#89fdd778 peer:InputPeer id:int = InputMedia;messageMediaStory#68cb6283 flags:# via_mention:flags.1?true peer:Peer id:int story:flags.0?StoryItem = MessageMedia;---functions---messages.sendMedia#ac55d9c1 flags:# silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true allow_paid_floodskip:flags.19?true peer:InputPeer reply_to:flags.0?InputReplyTo media:InputMedia message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector<MessageEntity> schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long allow_paid_stars:flags.21?long suggested_post:flags.22?SuggestedPost = Updates;

只需使用messages.sendMedia,并传递一个引用所共享故事的inputMediaStory ,即可将故事作为消息分享到任何聊天中。

该故事将以messageMediaStory的形式分享,并应显示为由故事发布者转发的消息(即使未使用messages.forwardMessages且消息fwd_from字段未设置)。

如果故事发布者在故事标题中提及我们,则还会自动生成 一条包含messageMediaStory 的消息,其中包含来自故事发布者的标志。via_mention

正在获取交互列表

storyView#b0bdeac5 flags:# blocked:flags.0?true blocked_my_stories_from:flags.1?true user_id:long date:int reaction:flags.2?Reaction = StoryView; storyViewPublicForward#9083670b flags:# blocked:flags.0?true blocked_my_stories_from:flags.1?true message:Message = StoryView; storyViewPublicRepost#bd74cf49 flags:# blocked:flags.0?true blocked_my_stories_from:flags.1?true peer_id:Peer story:StoryItem = StoryView;stories.storyViewsList#59d78fc5 flags:# count:int views_count:int forwards_count:int reactions_count:int views:Vector<StoryView> chats:Vector<Chat> users:Vector<User> next_offset:flags.0?string = stories.StoryViewsList;storyReaction#6090d6d5 peer_id:Peer date:int reaction:Reaction = StoryReaction; storyReactionPublicForward#bbab2643 message:Message = StoryReaction; storyReactionPublicRepost#cfcd0f13 peer_id:Peer story:StoryItem = StoryReaction;stories.storyReactionsList#aa5f789c flags:# count:int reactions:Vector<StoryReaction> chats:Vector<Chat> users:Vector<User> next_offset:flags.0?string = stories.StoryReactionsList;storyViews#8d595cd6 flags:# has_viewers:flags.1?true views_count:int forwards_count:flags.2?int reactions:flags.3?Vector<ReactionCount> reactions_count:flags.4?int recent_viewers:flags.0?Vector<long> = StoryViews; stories.storyViews#de9eed1d views:Vector<StoryViews> users:Vector<User> = stories.StoryViews;---functions---stories.getStoryViewsList#7ed23c57 flags:# just_contacts:flags.0?true reactions_first:flags.2?true forwards_first:flags.3?true peer:InputPeer q:flags.1?string id:int offset:string limit:int = stories.StoryViewsList;stories.getStoryReactionsList#b9b2881f flags:# forwards_first:flags.2?true peer:InputPeer id:int reaction:flags.0?Reaction offset:flags.1?string limit:int = stories.StoryReactionsList;stories.getStoriesViews#28e16cc8 peer:InputPeer id:Vector<int> = stories.StoryViews;

使用stories.getStoryViewsList获取与我们发布的特定故事互动过的所有用户的完整列表,该列表以StoryView构造函数列表的形式返回;将返回的next_offset(如果存在)传递给offset分页器以浏览结果;完整列表始终仅对高级用户可见,并且对于非高级用户发布的故事,该列表将在故事过期后被删除。story_viewers_expire_period »秒后;如果故事仍然可见,has_viewers则会设置该标志。

上述方法仅适用于用户发布的故事,要获取频道/超级群组发布的故事的几乎完全相同的信息,请使用stories.getStoryReactionsList:两种方法返回的数据实际上几乎完全相同,唯一的区别在于:

对于其余部分,两种方法都会返回以下信息:

此外,可以使用stories.getStoriesViews获取一个或多个故事的浏览量、转发量、反应数和最近观看者列表等信息,只需调用一次不分页的方法即可,显然,它返回的信息可能比stories.getStoryViewsList少。

回复故事

inputReplyToStory#5881323a peer:InputPeer story_id:int = InputReplyTo;---functions---messages.sendMessage#fe05dc9a flags:# no_webpage:flags.1?true silent:flags.5?true background:flags.6?true clear_draft:flags.7?true noforwards:flags.14?true update_stickersets_order:flags.15?true invert_media:flags.16?true allow_paid_floodskip:flags.19?true peer:InputPeer reply_to:flags.0?InputReplyTo message:string random_id:long reply_markup:flags.2?ReplyMarkup entities:flags.3?Vector<MessageEntity> schedule_date:flags.10?int send_as:flags.13?InputPeer quick_reply_shortcut:flags.17?InputQuickReplyShortcut effect:flags.18?long allow_paid_stars:flags.21?long suggested_post:flags.22?SuggestedPost = Updates;

你可以使用messages.sendMessage、messages.sendMedia或任何其他发送消息的方法回复用户和超级群组发布的故事,将inputReplyToStory传递给它reply_to,其中包含发布故事的用户 ID(也必须是peer消息的目标)和故事 ID。

转发故事

storyFwdHeader#b826e150 flags:# modified:flags.3?true from:flags.0?Peer from_name:flags.1?string story_id:flags.2?int = StoryFwdHeader;storyItem#edf164f1 flags:# pinned:flags.5?true public:flags.7?true close_friends:flags.8?true min:flags.9?true noforwards:flags.10?true edited:flags.11?true contacts:flags.12?true selected_contacts:flags.13?true out:flags.16?true id:int date:int from_id:flags.18?Peer fwd_from:flags.17?StoryFwdHeader expire_date:int caption:flags.0?string entities:flags.1?Vector<MessageEntity> media:MessageMedia media_areas:flags.14?Vector<MediaArea> privacy:flags.2?Vector<PrivacyRule> views:flags.3?StoryViews sent_reaction:flags.15?Reaction albums:flags.19?Vector<int> = StoryItem;---functions---stories.sendStory#737fc2ec flags:# pinned:flags.2?true noforwards:flags.4?true fwd_modified:flags.7?true peer:InputPeer media:InputMedia media_areas:flags.5?Vector<MediaArea> caption:flags.0?string entities:flags.1?Vector<MessageEntity> privacy_rules:Vector<InputPrivacyRule> random_id:long period:flags.3?int fwd_from_id:flags.6?InputPeer fwd_from_story:flags.6?int albums:flags.8?Vector<int> = Updates;

可以使用stories.sendStory重新发布故事,fwd_from_story并在字段中填充原始故事 ID 和fwd_from_id发布原始故事的同行信息。

用户可以修改故事(例如,在媒体上叠加圆形视频反应);无论哪种方式,都必须media像往常一样将修改后的媒体或原始媒体传递到字段中,并且fwd_modified如果媒体已修改,则必须设置标志。

重新发布的故事将设置storyItem ,并使用storyFwdHeader构造函数填充,其中包含有关原始故事的信息。

搜索故事

foundStory#e87acbc0 peer:Peer story:StoryItem = FoundStory;stories.foundStories#e2de7737 flags:# count:int stories:Vector<FoundStory> next_offset:flags.0?string chats:Vector<Chat> users:Vector<User> = stories.FoundStories;---functions---stories.searchPosts#d1810907 flags:# hashtag:flags.0?string area:flags.1?MediaArea peer:flags.2?InputPeer offset:string limit:int = stories.FoundStories;
stories.searchPosts可用于全局搜索所有用户(甚至包括非联系人和其他我们从未见过的同行)的故事,可以使用传递给它的标签hashtag(不带#)或传递给它的位置标签area。

点击故事描述中的话题标签或点击位置标签时,应自动触发全局搜索(结果显示在地图下方)。

注意:仅当mediaAreaGeoPoint区域具有关联的address.

调用该方法时必须始终设置`hashtagor`参数,初始值必须为空字符串。通过重新调用该方法,并将`stories.foundStories`中上次调用返回的字段 传递给它,来对结果进行分页。areaoffset
offsetnext_offset

报道故事

inputReportReasonSpam#58dbcab8 = ReportReason; inputReportReasonViolence#1e22c78d = ReportReason; inputReportReasonPornography#2e59d922 = ReportReason; inputReportReasonChildAbuse#adf44ee3 = ReportReason; inputReportReasonOther#c1e4a2b1 = ReportReason; inputReportReasonCopyright#9b89f93a = ReportReason; inputReportReasonGeoIrrelevant#dbd4feed = ReportReason; inputReportReasonFake#f5ddd6e7 = ReportReason; inputReportReasonIllegalDrugs#a8eb2be = ReportReason; inputReportReasonPersonalDetails#9ec7863d = ReportReason;---functions---stories.report#19d8eb45 peer:InputPeer id:Vector<int> option:bytes message:string = ReportResult;

使用stories.report来报告一个或多个故事。

故事链接

exportedStoryLink#3fc9053b link:string = ExportedStoryLink;---functions---stories.exportStoryLink#7b8def20 peer:InputPeer id:int = ExportedStoryLink;

使用stories.exportStoryLink为特定故事生成故事深度链接。

当遇到故事深度链接时,客户应按照此处所述打开指定的故事 »。

请点击这里»查看更多关于故事深度链接的信息。

媒体区域

模式:

mediaAreaCoordinates#cfc9e002 flags:# x:double y:double w:double h:double rotation:double radius:flags.0?double = MediaAreaCoordinates;storyItem#edf164f1 flags:# pinned:flags.5?true public:flags.7?true close_friends:flags.8?true min:flags.9?true noforwards:flags.10?true edited:flags.11?true contacts:flags.12?true selected_contacts:flags.13?true out:flags.16?true id:int date:int from_id:flags.18?Peer fwd_from:flags.17?StoryFwdHeader expire_date:int caption:flags.0?string entities:flags.1?Vector<MessageEntity> media:MessageMedia media_areas:flags.14?Vector<MediaArea> privacy:flags.2?Vector<PrivacyRule> views:flags.3?StoryViews sent_reaction:flags.15?Reaction albums:flags.19?Vector<int> = StoryItem;---functions---stories.sendStory#737fc2ec flags:# pinned:flags.2?true noforwards:flags.4?true fwd_modified:flags.7?true peer:InputPeer media:InputMedia media_areas:flags.5?Vector<MediaArea> caption:flags.0?string entities:flags.1?Vector<MessageEntity> privacy_rules:Vector<InputPrivacyRule> random_id:long period:flags.3?int fwd_from_id:flags.6?InputPeer fwd_from_story:flags.6?int albums:flags.8?Vector<int> = Updates; stories.editStory#b583ba46 flags:# peer:InputPeer id:int media:flags.0?InputMedia media_areas:flags.3?Vector<MediaArea> caption:flags.1?string entities:flags.1?Vector<MessageEntity> privacy_rules:flags.2?Vector<InputPrivacyRule> = Updates;

故事可以有所谓的“媒体区域”:可点击的矩形区域,在故事上方带有动画叠加层,提供位置标签或互动等功能。

每个媒体区域的坐标和大小都在附加到每个MediaArea 的mediaAreaCoordinates构造函数中指定,有关更多信息, 请参阅构造函数页面 » 。

构造完成后,可以将MediaArea构造函数的向量传递给stories.sendStory或stories.editStory。

频道帖子

模式:

inputMediaAreaChannelPost#2271f2bf coordinates:MediaAreaCoordinates channel:InputChannel msg_id:int = MediaArea;mediaAreaChannelPost#770416af coordinates:MediaAreaCoordinates channel_id:long msg_id:int = MediaArea;

可以使用inputMediaAreaChannelPost/mediaAreaChannelPost将频道中的消息转发到故事中。

客户应根据媒体区域 获取并显示故事顶部的频道帖子副本coordinates:点击媒体区域应打开链接的帖子。

位置标签

模式:

geoPoint#b2a2f663 flags:# long:double lat:double access_hash:long accuracy_radius:flags.0?int = GeoPoint; geoPointAddress#de4c5d93 flags:# country_iso2:string state:flags.0?string city:flags.1?string street:flags.2?string = GeoPointAddress;mediaAreaGeoPoint#cad5452d flags:# coordinates:MediaAreaCoordinates geo:GeoPoint address:flags.0?GeoPointAddress = MediaArea; mediaAreaVenue#be82db9c coordinates:MediaAreaCoordinates geo:GeoPoint title:string address:string provider:string venue_id:string venue_type:string = MediaArea;inputMediaAreaVenue#b282217f coordinates:MediaAreaCoordinates query_id:long result_id:string = MediaArea;

位置标签由mediaAreaVenue或mediaAreaGeoPoint表示,与故事媒体顶部的位置贴纸相关联,并带有关联的可点击媒体区域。

这两个构造函数都有一个关联的地理位置,表示为geoPoint,并且有一个关于故事媒体上方可点击媒体区域的信息,表示为mediaAreaCoordinates构造函数。

mediaAreaGeoPoint用于表示简单的地理位置,并可选择包含文本地址。mediaAreaVenue用于表示特定场所(例如购物中心、商店、舞蹈学校等)的位置,除了场所的坐标外,它还包含地址的文本表示、场所名称()和场所类型/ID(/),格式由场所提供商在指定中支持。
titlevenue_idvenue_typeprovider

目前,唯一需要支持的提供商是foursquare。

要发送mediaAreaVenue,客户端应使用inputMediaAreaVenue,其构造方式如下:

客户只有在编辑故事时重新定位预先存在的 location 标签时才能重用现有的mediaAreaVenue;发布新故事或向现有故事添加新 location 标签时,请使用inputMediaAreaVenue 。

点击位置时应自动触发全局故事搜索» ,将mediaAreaGeoPoint/mediaAreaVenue传递给stories.searchPosts,并将结果显示在地图下方。

注意:仅当mediaAreaGeoPoint区域具有关联的address.

反应

模式:

reactionEmoji#1b2286b8 emoticon:string = Reaction; reactionCustomEmoji#8935fc73 document_id:long = Reaction;mediaAreaSuggestedReaction#14455871 flags:# dark:flags.0?true flipped:flags.1?true coordinates:MediaAreaCoordinates reaction:Reaction = MediaArea;updateSentStoryReaction#7d627683 peer:Peer story_id:int reaction:Reaction = Update;updateNewStoryReaction#1824e40b story_id:int peer:Peer reaction:Reaction = Update;---functions---stories.sendReaction#7fd736b2 flags:# add_to_recent:flags.0?true peer:InputPeer story_id:int reaction:Reaction = Updates;

故事反应是通过一个简单的 UI 按钮实现的,该按钮允许用户使用stories.sendReaction发送任何反应。

发送此方法将向所有已登录会话返回updateSentStoryReaction更新。如果已按此处所述启用,则当用户对故事做出反应时,
故事发布者还会收到updateNewStoryReaction更新。

不过,故事发布者也可以使用mediaAreaSuggestedReaction 媒体区域 »来建议一些特定的反应,这些反应以简单的可点击按钮的形式呈现:它们被渲染成一个圆形的漫画风格对话框,其“尾巴”位于右侧,背景为白色,反应»的输入reaction框位于对话框中心。
如果dark设置了该标志,则背景应为黑色。
如果flipped设置了该标志,则“尾巴”应位于左侧。可以添加到故事中的故事反应媒体区域的最大数量由stories_suggested_reactions_limit_* »配置键指定。点击该区域应像往常一样
调用stories.sendReaction 。

点击此处»了解更多关于如何获取文章评论列表的信息。

网址

mediaAreaUrl#37381085 coordinates:MediaAreaCoordinates url:string = MediaArea;

URL 媒体区域提供贴纸,点击这些贴纸时,应向用户提供提示(以贴纸上的工具提示形式实现),以打开指定的文件url。

stories_area_url_max 可添加到故事中的 URL 媒体区域的最大数量由»config 键指定。

天气

mediaAreaWeather#49a6549ccoordinates:MediaAreaCoordinates emoji:string temperature_c:double color:int = MediaArea;---functions---messages.getInlineBotResults#514e999d flags:# bot:InputUser peer:InputPeer geo_point:flags.0?InputGeoPoint query:string offset:string = messages.BotResults;

用户现在可以通过在故事中添加一个由mediaAreaWeather表示的天气媒体区域来分享天气信息。

天气媒体区域应使用 中指定的背景 ARGB 颜色进行渲染color,并应包含 中指定的表情符号emoji(渲染为动画表情符号),然后是 中指定的温度temperature_c(摄氏度,如果设备设置需要,客户端应将其转换为华氏度),然后是°C或,°F具体取决于所使用的单位。

为了在发布新闻时获取创建天气媒体区域所需的当前温度和表情符号,客户端应在内部使用messages.getInlineBotResults向weather_search_username客户端配置参数中指定的对象发起内联查询,并将用户的当前位置和inputPeerEmpty作为参数传递。此查询将返回一个botInlineResult:要使用的表情符号将包含在botInlineResult中,温度(始终以摄氏度为单位)也将包含在botInlineResult中。(它只包含值,不包含单位,因此可以轻松将其转换为 double 类型)。botgeo_pointpeer
emojititledescription

当用户创建新的天气媒体区域时,客户端应该在内部进行内联查询,而不是显示通常的内联查询 UI,而是将内联查询视为 API 调用,以获取当前用户位置的天气。

如果story_weather_preload客户端配置参数等于 true,则客户端应在启动时使用上述流程预加载天气(而不是仅在创建天气媒体区域时执行)。

收藏礼品

模式:

mediaAreaStarGift#5787686d coordinates:MediaAreaCoordinates slug:string = MediaArea;

拥有的收藏品礼物 »可以使用mediaAreaStarGift在故事中分享,其中包含slug来自starGiftUnique的内容。slug,可以按照此处指定的方式进行解析 »。

隐身模式

高级用户可以启用隐身模式,清除他们在过去stories_stealth_past_period几秒钟内打开的所有故事的视图»,并在接下来的stories_stealth_future_period几秒钟内隐藏他们对故事的视图»,具体由客户端配置决定»。

模式:

storiesStealthMode#712e27fd flags:# active_until_date:flags.0?int cooldown_until_date:flags.1?int = StoriesStealthMode;updateStoriesStealthMode#2c084dc1 stealth_mode:StoriesStealthMode = Update;---functions---stories.activateStealthMode#57bbd166 flags:# past:flags.0?true future:flags.1?true = Updates;

调用stories.activateStealthMode来激活隐身模式,传递past标志以删除过去几stories_stealth_past_period秒钟内打开的任何故事的视图 »和/或传递future标志以隐藏接下来stories_stealth_future_period几秒钟内的未来故事视图 »。

客户端只能按照客户端配置指定的stories_stealth_cooldown_period秒数调用此方法:在冷却时间到期之前调用该方法将触发错误,其中是冷却时间到期前剩余的秒数。FLOOD_WAIT_XX

将返回一个updateStoriesStealthMode构造函数,其中包含以下字段:

统计数据

stats.storyStats#50cd067c views_graph:StatsGraph reactions_by_emotion_graph:StatsGraph = stats.StoryStats;publicForwardMessage#1f2bf4a message:Message = PublicForward; publicForwardStory#edf3add0 peer:Peer story:StoryItem = PublicForward;stats.publicForwards#93037e20 flags:# count:int forwards:Vector<PublicForward> next_offset:flags.0?string chats:Vector<Chat> users:Vector<User> = stats.PublicForwards;---functions---stats.getStoryStats#374fef40 flags:# dark:flags.0?true peer:InputPeer id:int = stats.StoryStats;stats.getStoryPublicForwards#a6437ef6 peer:InputPeer id:int offset:string limit:int = stats.PublicForwards;

使用stats.getStoryStats获取有关故事的统计信息;返回的StatsGraph图表可以按照此处所述进行渲染»。

使用stats.getStoryPublicForwards获取故事的转发信息,包括以消息形式发送到公共聊天室和通过公共频道转发的信息。