自定义表情符号
Telegram允许在消息中添加动态和静态自定义表情符号。
自定义表情符号实体
messageEntityCustomEmoji#c8cf05f8 offset:int length:int document_id:long = MessageEntity;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;documentAttributeCustomEmoji#fd149899 flags:# free:flags.0?true text_color:flags.1?true alt:string stickerset:InputStickerSet = DocumentAttribute;---functions---messages.getCustomEmojiDocuments#d9ab0f54 document_id:Vector<long> = Vector<Document>;
自定义表情符号是一种特殊的实体 »,它只包含一个document_id,可以将其传递给messages.getCustomEmojiDocuments来获取应该向用户显示的静态、动态或视频贴纸表情符号,如贴纸文档中所述。
自定义表情符号文档将包含documentAttributeCustomEmoji属性,而不是documentAttributeSticker属性,其中包含有关关联表情符号的信息(alt)、该表情符号是否可供非高级用户使用(free)以及关联的stickerset。
如果设置了documentAttributeCustomEmoji标志,text_color则此 TGS 自定义表情符号的颜色在消息中使用时应更改为文本颜色,用作表情符号状态时应更改为强调色,在聊天照片中应更改为白色,或根据上下文更改为其他合适的颜色。
请注意,发送带有自定义表情符号的消息时,messageEntityCustomEmoji 实体 »必须在相关文本中恰好包裹一个常规表情符号(documentAttributeCustomEmoji中包含的表情符号)alt,否则服务器将忽略它。
与贴纸一样,自定义表情符号也按贴纸集进行组织:请参阅贴纸文档»以了解有关如何使用它们的更多信息。
要发送包含一个或多个自定义表情符号的消息,请创建messageEntityCustomEmoji 实体并将其附加到消息中。
请注意,您可以附加的自定义表情符号数量有限制,具体数量由appConfig 字段message_animated_emoji_max指定。
表情符号类别
自定义表情符号选择界面应提供类别列表,以便按表情符号(列表)或其他条件快速筛选结果,详情 请参见此处» 。
表情符号关键词
emojiKeyword#d5b3b9f9 keyword:string emoticons:Vector<string> = EmojiKeyword; emojiKeywordDeleted#236df622 keyword:string emoticons:Vector<string> = EmojiKeyword;emojiKeywordsDifference#5cc761bd lang_code:string from_version:int version:int keywords:Vector<EmojiKeyword> = EmojiKeywordsDifference;emojiLanguage#b3fb5361 lang_code:string = EmojiLanguage; emojiURL#a575739d url:string = EmojiURL;---functions---messages.getEmojiKeywords#35a0e062 lang_code:string = EmojiKeywordsDifference; messages.getEmojiKeywordsDifference#1508b6af lang_code:string from_version:int = EmojiKeywordsDifference; messages.getEmojiKeywordsLanguages#4e9963b2 lang_codes:Vector<string> = Vector<EmojiLanguage>;messages.getEmojiURL#d5b10c26 lang_code:string = EmojiURL;
首先,调用`messages.getEmojiKeywordsLanguages`获取用于获取表情符号关键词列表的语言列表:通常,该方法会返回传入的语言代码(如果已本地化)以及en一些类似语言的语言代码(如果适用)。
然后,对所有返回的语言代码调用`messages.getEmojiKeywords`来获取与 UTF-8 表情符号关联的本地化关键词列表。
使用返回的关键字,允许用户按关键字搜索表情符号和自定义表情符号,同时显示与关键字关联的 UTF-8 表情符号以及与这些 UTF-8 表情符号关联的自定义表情符号。
定期调用messages.getEmojiKeywordsDifference来获取本地存储的所有语言的关键字列表的更新。
messages.getEmojiURL可用于获取 HTTP URL,该 URL 可用于自动登录翻译平台并建议新的表情符号关键字:该 URL 在生成后 30 秒内有效。
此外,自定义表情符号和非口罩贴纸也可能具有一组自定义关键字,这些关键字会在自定义表情符号贴纸集信息中返回:
stickerKeyword#fcfeb29c document_id:long keyword:Vector<string> = StickerKeyword;messages.stickerSet#6e153f16 set:StickerSet packs:Vector<StickerPack> keywords:Vector<StickerKeyword> documents:Vector<Document> = messages.StickerSet;stickerSetFullCovered#40d13c0e set:StickerSet packs:Vector<StickerPack> keywords:Vector<StickerKeyword> documents:Vector<Document> = StickerSetCovered;