You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Telegram表情分享链接获取对应全部表情?

获取Telegram表情分享链接的全部表情

这类t.me/addemoji/xxx链接指向的是Telegram的自定义表情集(本质是贴纸集),可以通过Telethon或Pyrogram的贴纸集API直接获取所有表情,以下是具体实现:

方法一:Telethon实现

  1. 从链接里提取表情集的短名称,比如https://t.me/addemoji/CyrillicFont的短名称就是CyrillicFont
  2. 使用get_sticker_set接口获取表情集对象,遍历其中的贴纸列表提取表情信息
from telethon import TelegramClient
from telethon.tl.types import InputStickerSetShortName

# 替换成你自己的API信息
api_id = 123456
api_hash = 'your_api_hash_here'
client = TelegramClient('emoji_session', api_id, api_hash)

async def grab_emoji_set(short_name):
    # 获取目标表情集
    sticker_set = await client.get_sticker_set(InputStickerSetShortName(short_name=short_name))
    # 遍历所有表情
    for idx, sticker in enumerate(sticker_set.stickers, 1):
        print(f"表情{idx}: {sticker.emoticon} | 文件ID: {sticker.document.id}")

# 运行脚本
with client:
    client.loop.run_until_complete(grab_emoji_set('CyrillicFont'))

方法二:Pyrogram实现

逻辑和Telethon一致,调用Pyrogram的get_sticker_set接口即可:

from pyrogram import Client

# 替换成你自己的API信息
api_id = 123456
api_hash = 'your_api_hash_here'
app = Client('emoji_bot', api_id, api_hash)

async def fetch_emoji_collection(short_name):
    sticker_set = await app.get_sticker_set(short_name)
    for idx, sticker in enumerate(sticker_set.stickers, 1):
        print(f"表情{idx}: {sticker.emoji} | 文件ID: {sticker.file_id}")

# 运行脚本
with app:
    app.run(fetch_emoji_collection('emoji_by_robot'))

注意事项

  • 你需要先在my.telegram.org申请自己的API ID和API Hash,才能正常调用Telegram的接口
  • 若遇到权限问题,先在Telegram客户端打开目标链接添加一次表情集,再运行脚本即可
  • 这些自定义表情在Telegram系统里属于贴纸集范畴,所以需要用贴纸相关的API来获取

内容的提问来源于stack exchange,提问作者Jason

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.22 19:12:28