使用贴纸

Telegram客户端支持显示静态和动态贴纸。

展示贴纸

document#8fd4c4d8 flags:# id:long access_hash:long file_reference:bytes date:int mime_type:string size:long thumbs:flags.0?Vector<PhotoSize> video_thumbs:flags.1?Vector<VideoSize> dc_id:int attributes:Vector<DocumentAttribute> = Document;documentAttributeSticker#6319d612 flags:# mask:flags.1?true alt:string stickerset:InputStickerSet mask_coords:flags.0?MaskCoords = DocumentAttribute;inputStickerSetEmpty#ffb62b95 = InputStickerSet; inputStickerSetID#9de7a269 id:long access_hash:long = InputStickerSet; inputStickerSetShortName#861cc8a0 short_name:string = InputStickerSet; inputStickerSetAnimatedEmoji#28703c8 = InputStickerSet; inputStickerSetDice#e67f520e emoticon:string = InputStickerSet; inputStickerSetAnimatedEmojiAnimations#cde3739 = InputStickerSet; inputStickerSetPremiumGifts#c88b3b02 = InputStickerSet; inputStickerSetEmojiGenericAnimations#4c4d4ce = InputStickerSet; inputStickerSetEmojiDefaultStatuses#29d0f5ee = InputStickerSet; inputStickerSetEmojiDefaultTopicIcons#44c1f8e9 = InputStickerSet; inputStickerSetEmojiChannelDefaultStatuses#49748553 = InputStickerSet;

贴纸可以包含在附加到消息的文档构造器中,并且始终具有documentAttributeSticker类型的属性。

documentAttributeSticker属性包含有关关联的贴纸集、代表贴纸的表情符号等信息。

有多种类型的贴纸可供选择:

与所有文件一样,贴纸也有一组预览图,应按照此处所述进行处理 »。

贴纸按贴纸集进行组织,也用于以下情况:

一套贴纸可以包含静态贴纸、动态贴纸和视频贴纸。

静电贴纸

静态贴纸是具有以下规格的WebP图像:

它们通过mime_type关联文档的字段进行标识,始终等于image/webp。

点击此处»查看如何创建完美的静态贴纸的技巧,点击此处»查看如何使用 API 上传贴纸的信息。

动态贴纸

动态贴纸是Lottie 矢量动画 »。

Telegram 使用特殊的.tgslottie 动画文件格式,它由 gzip 压缩的 bodymovin JSON 文件组成,可以使用rlottie库播放。

Lottie动画规格:

它们通过mime_type关联文档的字段进行标识,始终等于application/x-tgsticker。

点击此处»查看如何创建完美的动画贴纸的技巧,点击此处»查看如何使用 API 上传贴纸的信息。

高级动画贴纸特效
document#8fd4c4d8 flags:# id:long access_hash:long file_reference:bytes date:int mime_type:string size:long thumbs:flags.0?Vector<PhotoSize> video_thumbs:flags.1?Vector<VideoSize> dc_id:int attributes:Vector<DocumentAttribute> = Document;videoSize#de33b094 flags:# type:string w:int h:int size:int video_start_ts:flags.0?double = VideoSize;inputDocumentFileLocation#bad07584 id:long access_hash:long file_reference:bytes thumb_size:string = InputFileLocation;

一些动画贴纸还附带动画效果(作为另一个 Lottie 动画),该效果应在贴纸进入视口后播放。

此效果比贴纸本身更大,应该位于主贴纸动画下方,但也应该位于任何其他附近的 UI 元素上方。

当贴纸首次滚动到屏幕上时,应该播放该音乐;如果聊天窗口关闭后再重新打开,则应该再次播放该音乐。

只有高级会员才能发送高级贴纸,而动画效果应该对所有用户(包括没有高级会员的用户)都有效。

高级贴纸可通过其主文档中是否存在videoSize来识别。动画效果的 TGS 文件(与贴纸本身的 TGS 文件不同)可通过使用inputDocumentFileLocation并指定 来获取,如这里所述 »。type=f
thumb_size=f

请注意,动画消息特效»也可以重复使用高级贴纸的动画特效。

此外,高级动画贴纸可以附带额外的动画消息效果»,在这种情况下,贴纸效果和附加效果应该同时播放。

视频贴纸

视频贴纸是VP9视频,规格如下:

它们通过mime_type关联文档的字段进行标识,始终等于video/webm。

点击此处»查看如何创建完美的视频贴纸的技巧,点击此处»查看如何使用 API 上传视频贴纸的信息。

贴纸套装

inputStickerSetID#9de7a269 id:long access_hash:long = InputStickerSet; inputStickerSetShortName#861cc8a0 short_name:string = InputStickerSet; inputStickerSetAnimatedEmoji#28703c8 = InputStickerSet; inputStickerSetDice#e67f520e emoticon:string = InputStickerSet; inputStickerSetAnimatedEmojiAnimations#cde3739 = InputStickerSet; inputStickerSetPremiumGifts#c88b3b02 = InputStickerSet; inputStickerSetEmojiGenericAnimations#4c4d4ce = InputStickerSet; inputStickerSetEmojiDefaultStatuses#29d0f5ee = InputStickerSet; inputStickerSetEmojiDefaultTopicIcons#44c1f8e9 = InputStickerSet; inputStickerSetEmojiChannelDefaultStatuses#49748553 = InputStickerSet;messages.stickerSet#6e153f16 set:StickerSet packs:Vector<StickerPack> keywords:Vector<StickerKeyword> documents:Vector<Document> = messages.StickerSet; messages.stickerSetNotModified#d3f924eb = messages.StickerSet;stickerSet#2dd14edc flags:# archived:flags.1?true official:flags.2?true masks:flags.3?true emojis:flags.7?true text_color:flags.9?true channel_emoji_status:flags.10?true creator:flags.11?true installed_date:flags.0?int id:long access_hash:long title:string short_name:string thumbs:flags.4?Vector<PhotoSize> thumb_dc_id:flags.4?int thumb_version:flags.4?int thumb_document_id:flags.8?long count:int hash:int = StickerSet;stickerPack#12b299d4 emoticon:string documents:Vector<long> = StickerPack;---functions---messages.getStickerSet#c8a0ec74 stickerset:InputStickerSet hash:int = messages.StickerSet;

贴纸被分组到所谓的贴纸包中:但是,在 API 中它们被称为“贴纸集”,而“贴纸包”这个名称则保留用于其他用途,请继续阅读以获取更多信息。

使用messages.getStickerSet获取有关贴纸集的信息,并提供以下参数:

如果提供了非零值,且贴纸集自上次获取以来未被修改,则该方法将返回messages.stickerSetNotModified。否则,将返回messages.stickerSet ,其中包含:hash

贴纸套装预览

stickerSetCovered#6410a5d2 set:StickerSet cover:Document = StickerSetCovered; stickerSetMultiCovered#3407e51b set:StickerSet covers:Vector<Document> = StickerSetCovered; stickerSetFullCovered#40d13c0e set:StickerSet packs:Vector<StickerPack> keywords:Vector<StickerKeyword> documents:Vector<Document> = StickerSetCovered;

API 的某些部分可能会返回StickerSetCovered 的部分构造函数,而不是集合中每个贴纸的完整文档构造函数:

此外,与所有文件一样,贴纸文档也有一组预览,应按照此处所述进行处理 »。

安装贴纸套装

inputStickerSetID#9de7a269 id:long access_hash:long = InputStickerSet; inputStickerSetShortName#861cc8a0 short_name:string = InputStickerSet; inputStickerSetAnimatedEmoji#28703c8 = InputStickerSet; inputStickerSetDice#e67f520e emoticon:string = InputStickerSet; inputStickerSetAnimatedEmojiAnimations#cde3739 = InputStickerSet; inputStickerSetPremiumGifts#c88b3b02 = InputStickerSet; inputStickerSetEmojiGenericAnimations#4c4d4ce = InputStickerSet; inputStickerSetEmojiDefaultStatuses#29d0f5ee = InputStickerSet; inputStickerSetEmojiDefaultTopicIcons#44c1f8e9 = InputStickerSet; inputStickerSetEmojiChannelDefaultStatuses#49748553 = InputStickerSet;messages.stickerSetInstallResultSuccess#38641628 = messages.StickerSetInstallResult; messages.stickerSetInstallResultArchive#35e410a8 sets:Vector<StickerSetCovered> = messages.StickerSetInstallResult;messages.allStickersNotModified#e86602c3 = messages.AllStickers; messages.allStickers#cdbbcebb hash:long sets:Vector<StickerSet> = messages.AllStickers;updateNewStickerSet#688a30aa stickerset:messages.StickerSet = Update; updateStickerSetsOrder#bb2d201 flags:# masks:flags.0?true emojis:flags.1?true order:Vector<long> = Update; updateStickerSets#31c24808 flags:# masks:flags.0?true emojis:flags.1?true = Update;---functions---messages.installStickerSet#c78fe460 stickerset:InputStickerSet archived:Bool = messages.StickerSetInstallResult; messages.uninstallStickerSet#f96e55de stickerset:InputStickerSet = Bool; messages.toggleStickerSets#b5052fea flags:# uninstall:flags.0?true archive:flags.1?true unarchive:flags.2?true stickersets:Vector<InputStickerSet> = Bool; messages.reorderStickerSets#78337739 flags:# masks:flags.0?true emojis:flags.1?true order:Vector<long> = Bool; messages.getAllStickers#b8a0a1a8 hash:long = messages.AllStickers; messages.getMaskStickers#640f82b8 hash:long = messages.AllStickers; messages.getEmojiStickers#fbfca18f hash:long = messages.AllStickers;

可以使用messages.installStickerSet安装贴纸集,可能的返回值如下:archived=false

使用messages.uninstallStickerSet或messages.toggleStickerSets并加上uninstall标志来卸载一个或多个贴纸集。

安装贴纸集时,会向其他已登录会话发出updateNewStickerSet更新。

卸载或归档贴纸集时,会向其他已登录会话发出updateStickerSets更新。
此更新应触发对以下方法的调用:

使用messages.reorderStickerSets按stickerSetID重新排序已安装的贴纸集:请注意,普通贴纸集、遮罩贴纸集和自定义表情符号贴纸集是独立排序的,请使用相应的标志对正确的贴纸集类型进行排序。

重新排序贴纸集时,将向其他已登录会话发出updateStickerSetsOrder更新。
此更新应触发对messages.getAllStickers、messages.getArchivedStickers和messages.getEmojiStickers 的调用。

使用messages.getAllStickers获取所有已安装且未归档的贴纸集。
使用messages.getEmojiStickers获取所有已安装且未归档的自定义表情贴纸集。

创建贴纸集

inputStickerSetItem#32da9e9c flags:# document:InputDocument emoji:string mask_coords:flags.0?MaskCoords keywords:flags.1?string = InputStickerSetItem;messages.stickerSet#6e153f16 set:StickerSet packs:Vector<StickerPack> keywords:Vector<StickerKeyword> documents:Vector<Document> = messages.StickerSet; messages.stickerSetNotModified#d3f924eb = messages.StickerSet;messages.myStickers#faff629d count:int sets:Vector<StickerSetCovered> = messages.MyStickers;stickers.suggestedShortName#85fea03f short_name:string = stickers.SuggestedShortName;---functions---messages.uploadMedia#14967978 flags:# business_connection_id:flags.0?string peer:InputPeer media:InputMedia = MessageMedia;stickers.checkShortName#284b3639 short_name:string = Bool; stickers.suggestShortName#4dafc503 title:string = stickers.SuggestedShortName;stickers.createStickerSet#9021ab67 flags:# masks:flags.0?true emojis:flags.5?true text_color:flags.6?true user_id:InputUser title:string short_name:string thumb:flags.2?InputDocument stickers:Vector<InputStickerSetItem> software:flags.3?string = messages.StickerSet;messages.getMyStickers#d0b5e1fc offset_id:long limit:int = messages.MyStickers;stickers.addStickerToSet#8653febe stickerset:InputStickerSet sticker:InputStickerSetItem = messages.StickerSet; stickers.replaceSticker#4696459a sticker:InputDocument new_sticker:InputStickerSetItem = messages.StickerSet; stickers.removeStickerFromSet#f7760f51 sticker:InputDocument = messages.StickerSet; stickers.changeStickerPosition#ffb6d4ca sticker:InputDocument position:int = messages.StickerSet; stickers.setStickerSetThumb#a76a5392 flags:# stickerset:InputStickerSet thumb:flags.0?InputDocument thumb_document_id:flags.1?long = messages.StickerSet;

机器人和用户可以通过以下方法创建贴纸集。之前用于编辑贴纸的@stickers
机器人现已弃用,请改用应用内编辑器(调用以下方法)。

请注意,非官方机器人创建贴纸集时,必须"_by_<bot_username>"在贴纸集简称前添加前缀。用户和机器人可以直接修改使用`stickers.createStickerSet`和`@stickers`创建的贴纸集:当前用户/机器人拥有的贴纸集将带有creator相应的标记。

使用messages.getMyStickers获取当前帐户创建的贴纸集。

如果您还没有可以访问先前上传的文档,请使用messages.uploadMedia上传贴纸和缩略图。

使用stickers.checkShortName检查给定的短名称是否可用,使用stickers.suggestShortName让服务器根据贴纸集标题建议一个短名称。

使用stickers.createStickerSet创建普通、遮罩和自定义表情符号贴纸集,也可以在使用 stickers SDK 导入贴纸时使用。

使用stickers.addStickerToSet将贴纸添加到贴纸集。
使用stickers.replaceSticker替换贴纸集中的贴纸(无需提供实际的贴纸集 ID)。
使用stickers.setStickerSetThumb在创建后编辑贴纸集缩略图。
使用stickers.removeStickerFromSet从贴纸集中移除贴纸,使用stickers.changeStickerPosition移动贴纸集中的贴纸位置(只需提供贴纸文档即可)。

搜索贴纸集

messages.foundStickerSetsNotModified#d54b65d = messages.FoundStickerSets; messages.foundStickerSets#8af09dd2 hash:long sets:Vector<StickerSetCovered> = messages.FoundStickerSets;---functions---messages.searchStickerSets#35705b8a flags:# exclude_featured:flags.0?true q:string hash:long = messages.FoundStickerSets;messages.searchEmojiStickerSets#92b4494c flags:# exclude_featured:flags.0?true q:string hash:long = messages.FoundStickerSets;

您可以使用messages.searchStickerSets和messages.searchEmojiStickerSets按名称搜索全局可用的普通贴纸集和自定义表情符号贴纸集:请注意,此方法返回一组贴纸集预览。

搜索贴纸

messages.foundStickersNotModified#6010c534 flags:# next_offset:flags.0?int = messages.FoundStickers; messages.foundStickers#82c9e290 flags:# next_offset:flags.0?int hash:long stickers:Vector<Document> = messages.FoundStickers;---functions---messages.searchStickers#29b1c66a flags:# emojis:flags.0?true q:string emoticon:string lang_code:Vector<string> offset:int limit:int hash:long = messages.FoundStickers;您可以使用messages.searchStickers搜索全球可用的普通和自定义表情符号贴纸 »使用关键字 (q) 以多种语言(可以在 中提供lang_code)和/或空格分隔的表情符号列表 (emoticon)。


得益于服务器端定制的 AI 模型,该方法支持包含多个关键词的复杂搜索。

精选贴纸套装

messages.featuredStickersNotModified#c6dc0c66 count:int = messages.FeaturedStickers; messages.featuredStickers#be382906 flags:# premium:flags.0?true hash:long count:int sets:Vector<StickerSetCovered> unread:Vector<long> = messages.FeaturedStickers;updateReadFeaturedStickers#571d2742 = Update; updateReadFeaturedEmojiStickers#fb4c496c = Update;---functions---messages.getFeaturedStickers#64780b14 hash:long = messages.FeaturedStickers; messages.readFeaturedStickers#5b118126 id:Vector<long> = Bool;messages.getOldFeaturedStickers#7ed094a1 offset:int limit:int hash:long = messages.FeaturedStickers;messages.getFeaturedEmojiStickers#ecf6736 hash:long = messages.FeaturedStickers;

Telegram 展示了一系列精选贴纸集:可以使用messages.getFeaturedStickers或messages.getFeaturedEmojiStickers获取它们,用于自定义表情符号。

preload_featured_stickers客户端应根据配置参数的值在启动时预加载特色贴纸。

该方法还会返回一组未读的stickerSetIDunread:使用messages.readFeaturedStickers将它们标记为已读:请注意,这只会影响该unread字段,所有 stickerSet 仍将被返回,除非您还生成了hash。
此方法还会向所有其他已登录会话 发出updateReadFeaturedStickers或updateReadFeaturedEmojiStickers更新。

messages.getOldFeaturedStickers可用于获取包含更多特色贴纸集的扩展列表,这些贴纸集之前曾在messages.getFeaturedStickers返回的短列表中出现过。

最喜欢的贴纸套装

messages.favedStickersNotModified#9e8fa6d3 = messages.FavedStickers; messages.favedStickers#2cb51097 hash:long packs:Vector<StickerPack> stickers:Vector<Document> = messages.FavedStickers;updateFavedStickers#e511996d = Update;---functions---messages.faveSticker#b9ffc55b id:InputDocument unfave:Bool = Bool; messages.getFavedStickers#4f1aaa9 hash:long = messages.FavedStickers;

可以使用messages.faveSticker将贴纸集添加到收藏夹或取消收藏夹。

可以使用messages.getFavedStickers获取收藏的贴纸:请注意,此方法返回一组贴纸集预览 »。

用户只能收藏一定数量的贴纸集,具体数量由以下配置参数决定:

  • 高级用户可以收藏总共 1000 套stickers_faved_limit_premium贴纸。
  • 非高级用户可以收藏总共 个stickers_faved_limit_default贴纸集。

当用户收藏或取消收藏贴纸集时,会向其他已登录会话发出updateFavedStickers更新。
此更新应触发对messages.getFavedStickers 的调用。

已存档的贴纸集

messages.archivedStickers#4fcba9c8 count:int sets:Vector<StickerSetCovered> = messages.ArchivedStickers;updateStickerSets#31c24808 flags:# masks:flags.0?true emojis:flags.1?true = Update;---functions---messages.installStickerSet#c78fe460 stickerset:InputStickerSet archived:Bool = messages.StickerSetInstallResult; messages.toggleStickerSets#b5052fea flags:# uninstall:flags.0?true archive:flags.1?true unarchive:flags.2?true stickersets:Vector<InputStickerSet> = Bool;messages.getArchivedStickers#57f17692 flags:# masks:flags.0?true emojis:flags.1?true offset_id:long limit:int = messages.ArchivedStickers;

可以使用messages.installStickerSet来归档(或取消归档)一个或多个贴纸集archived=true|false,或者使用messages.toggleStickerSets并加上archive或unarchive标志。

安装新的贴纸集时,未使用的贴纸集也可能会自动存档。

messages.getAllStickers不会返回已存档的贴纸,只能使用messages.getArchivedStickers获取:请注意,此方法返回一组贴纸集预览 »。

当归档或取消归档贴纸集时,会向其他已登录会话发出updateStickerSets更新。
此更新应触发对messages.getArchivedStickers 的调用。

最新贴纸

messages.recentStickersNotModified#b17f890 = messages.RecentStickers; messages.recentStickers#88d37c56 hash:long packs:Vector<StickerPack> stickers:Vector<Document> dates:Vector<int> = messages.RecentStickers;updateRecentStickers#9a422c20 = Update;---functions---messages.saveRecentSticker#392718f8 flags:# attached:flags.0?true id:InputDocument unsave:Bool = Bool; messages.getRecentStickers#9da9403b flags:# attached:flags.0?true hash:long = messages.RecentStickers; messages.clearRecentStickers#8999602d flags:# attached:flags.0?true = Bool;

在消息中使用贴纸后,客户端应调用messages.saveRecentSticker(仅限普通贴纸和遮罩贴纸,遮罩贴纸应设置attached标志)。

然后可以使用messages.saveRecentSticker从最近使用的贴纸列表中删除贴纸;可以使用messages.clearRecentStickersunsave=true清除整个列表。

使用messages.getRecentStickers获取最近使用的贴纸列表。

stickers_recent_limit用户只能根据配置参数的值添加一定数量的最新贴纸。

修改最近使用的贴纸列表时,会向其他已登录的会话发出updateRecentStickers更新。
此更新应触发对messages.getRecentStickers 的调用。

最新贴纸套装

updateMoveStickerSetToTop#86fccf85 flags:# masks:flags.0?true emojis:flags.1?true stickerset:long = Update;---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.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.sendMultiMedia#1bf89d74 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 multi_media:Vector<InputSingleMedia> 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 = Updates;

当手动从贴纸集选择栏中update_stickersets_order选择并使用特定贴纸集中的贴纸、蒙版和自定义表情符号时(而非通过“建议”或“最近使用”贴纸集界面),应设置此标志。
请注意,对于自定义表情符号,仅当手动从单个自定义表情符号贴纸集中选择自定义表情符号时(而非多个自定义表情符号贴纸集)才应设置此标志。

设置此标志将触发updateMoveStickerSetToTop更新(而不是通常的updateStickerSetsOrder/updateStickerSets更新),表明已安装的贴纸集列表已重新排序,并且指定的贴纸集已移至顶部。

请注意,API 还提供了一个单独的最近贴纸列表(不是贴纸集),请点击此处»了解更多信息。

表情符号类别

贴纸选择界面应该提供一个类别列表,以便按表情符号(列表)或其他条件快速筛选结果,详情 请参见此处» 。

贴纸建议

messages.stickersNotModified#f1749a22 = messages.Stickers; messages.stickers#30a6ec7e hash:long stickers:Vector<Document> = messages.Stickers;emojiListNotModified#481eadfa = EmojiList; emojiList#7a1e11d1 hash:long document_id:Vector<long> = EmojiList;---functions---messages.getStickers#d5a5d3a1 emoticon:string hash:long = messages.Stickers; messages.searchCustomEmoji#2c11c0d7 emoticon:string hash:long = EmojiList;

当用户在文本栏中输入表情符号时, 客户端应显示一个弹出窗口,其中包含建议的贴纸和自定义表情符号列表。

如果应用stickers_emoji_suggest_only_api配置参数设置为 true,客户端必须调用messages.getStickers或messages.searchCustomEmoji来获取表情符号的推荐贴纸/自定义表情符号列表。stickers_emoji_cache_time
应用配置参数指定messages.getStickers或messages.searchCustomEmoji本地缓存的有效期,这在调用该方法时生成分页哈希值时也很重要。

否则,应使用以下本地逻辑。

  • 根据表情符号,创建两个最近使用过的贴纸列表:
    • 列表a)包含所有非高级贴纸。
    • 列表b)包含所有高级贴纸。
  • 最终建议的贴纸列表c组成如下:
    • 如果用户没有高级订阅:显示a中的所有贴纸,然后显示bstickers_premium_by_emoji_num中的所有贴纸。
    • 如果用户拥有高级订阅:从astickers_normal_by_emoji_per_premium_num中选择贴纸,然后从b中选择 1 个贴纸,依此类推,直到两个列表都为空。

特殊贴纸

messages.stickersNotModified#f1749a22 = messages.Stickers; messages.stickers#30a6ec7e hash:long stickers:Vector<Document> = messages.Stickers;---functions---messages.getStickers#d5a5d3a1 emoticon:string hash:long = messages.Stickers;

UI 中的某些地方需要使用服务器指定的贴纸列表,该列表独立于已安装的贴纸集,可以使用messages.getStickers和特定值从服务器获取emoticon。

优质贴纸示例

用户界面中的某些地方可能需要显示高级贴纸列表,作为用户购买高级订阅后可以使用的贴纸示例。

要获取此特殊列表,请调用messages.getStickers并传入以下参数emoticon=

贺卡贴纸

当用户与没有聊天记录的用户打开私聊时,用户界面应显示随机选择的问候贴纸+发送消息的邀请。

要获取这个特殊的问候贴纸列表,请调用messages.getStickers并加上。emoticon=

请注意,如果启用了自定义Telegram Business 简介 »,则必须使用userFull中指定的消息+贴纸。intro

粘贴的贴纸

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;photo#fb197a65 flags:# has_stickers:flags.0?true id:long access_hash:long file_reference:bytes date:int sizes:Vector<PhotoSize> video_sizes:flags.1?Vector<VideoSize> dc_id:int = Photo;document#8fd4c4d8 flags:# id:long access_hash:long file_reference:bytes date:int mime_type:string size:long thumbs:flags.0?Vector<PhotoSize> video_thumbs:flags.1?Vector<VideoSize> dc_id:int attributes:Vector<DocumentAttribute> = Document; documentAttributeHasStickers#9801d2f7 = DocumentAttribute;inputStickeredMediaPhoto#4a992157 id:InputPhoto = InputStickeredMedia; inputStickeredMediaDocument#438865b id:InputDocument = InputStickeredMedia;inputStickerSetItem#32da9e9c flags:# document:InputDocument emoji:string mask_coords:flags.0?MaskCoords keywords:flags.1?string = InputStickerSetItem;stickerSetCovered#6410a5d2 set:StickerSet cover:Document = StickerSetCovered; stickerSetMultiCovered#3407e51b set:StickerSet covers:Vector<Document> = StickerSetCovered;---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.getAttachedStickers#cc5b67cc media:InputStickeredMedia = Vector<StickerSetCovered>;

各种贴纸都可以添加到照片和视频上。
首先,在本地将贴纸叠加到媒体文件上(正确处理可能存在的默认遮罩坐标),然后上传修改后的媒体文件。之后,在使用messages.sendMedia
发送媒体文件时,在inputMediaUploadedPhoto或inputMediaUploadedDocument字段中指定叠加的贴纸。stickers

发送的带贴纸照片将设置has_stickers标记。
发送的带贴纸视频文档将具有documentAttributeHasStickers属性。

当收到此类媒体文件时,客户端应调用messages.getAttachedStickers,并将媒体传递给该方法:该方法将返回一组贴纸集预览 »,其中包含有关媒体中使用的贴纸集(而不是贴纸)的信息。

口罩贴纸

面具贴纸是一种特殊的静电贴纸,旨在覆盖在照片上并附着在介质上,如这里所述 »。

maskCoords#aed6dbb2 n:int x:double y:double zoom:double = MaskCoords;documentAttributeSticker#6319d612 flags:# mask:flags.1?true alt:string stickerset:InputStickerSet mask_coords:flags.0?MaskCoords = DocumentAttribute;inputStickerSetItem#32da9e9c flags:# document:InputDocument emoji:string mask_coords:flags.0?MaskCoords keywords:flags.1?string = InputStickerSetItem;---functions---messages.getMaskStickers#640f82b8 hash:long = messages.AllStickers;

遮罩贴纸可以有关联的坐标,这些坐标包含在maskCoords构造函数中。

位置n指示口罩应放置的位置:

  • 0 => 相对于额头
  • 1 => 相对于眼睛
  • 2 => 相对于嘴巴
  • 3 => 相对于下巴

、和参数进一步细化相对于所选面部特征的位置x。yzoom

请注意,这些坐标仅用于在将贴纸添加到媒体时提供默认位置。这是通过本地运行人脸识别软件,并将贴纸放置在相对于所选面部特征的相应坐标位置来实现的。
用户可以在生成带有贴纸的新照片/视频之前修改最终的贴纸位置。
最终坐标不会随附加的媒体一起发送,因为它们仅用作放置贴纸时的建议默认位置。

默认坐标由贴纸集创建者在上传贴纸时选择。