rgxiao
V2EX  ›  Telegram

Telegram 怎么用代码获取到频道中的消息?

  •  
  •   rgxiao · Jun 18, 2024 · 3697 views
    This topic created in 697 days ago, the information mentioned may be changed or developed.

    有些频道的消息很有价值, 但是消息很多很多, 所以我想自己用代码把一些垃圾消息过滤掉, 只留下自己需要的消息, 但是我怎么获取这个频道的消息呢?

    13 replies    2024-06-24 19:58:57 +08:00
    03
        1
    03  
       Jun 18, 2024
    cherbium
        2
    cherbium  
       Jun 18, 2024
    先去申请一下,api id 和 hash (现在贼难申请),然后去 telegram api 专门提供了教程
    icoming
        3
    icoming  
       Jun 18, 2024
    @cherbium
    @03

    没有权限添加机器人,也能获取吗?
    03
        4
    03  
       Jun 18, 2024
    @icoming 这个应该是自定义客户端,和只能用 bot 身份的 bot api 不一样
    xbin
        5
    xbin  
       Jun 18, 2024
    tdl 主要是用来下载收藏的内容,也可以导出聊天记录
    https://github.com/iyear/tdl
    文档: https://docs.iyear.me/tdl/zh/

    https://docs.iyear.me/tdl/zh/guide/tools/export-messages/
    以 JSON 格式导出聊天、频道、群组等中的消息
    tdl chat export -c "频道 id" --all --with-content --raw
    xbin
        6
    xbin  
       Jun 18, 2024
    @xbin #5 隔壁男+论坛看到的,隔壁论坛有人有需求聊天记录导出 HTML,有兴趣的可以去看看 tid =2222162
    cherbium
        7
    cherbium  
       Jun 18, 2024
    @icoming
    不是机器人,是个人账户,telegram api ( tg 官方提供的针对账号的 api )
    cosette
        8
    cosette  
       Jun 18, 2024
    如果是公开频道,最简单的方式就是使用 rsshub 订阅,然后启用过滤器
    rgxiao
        9
    rgxiao  
    OP
       Jun 19, 2024
    @cherbium 请问 Telegram 账户有这种 api 么? 我清楚 bot 是有类似的 api, 但是账户有么?
    rgxiao
        10
    rgxiao  
    OP
       Jun 19, 2024
    @03 Telegram 账户是没有监听消息的 api 对么?
    rgxiao
        11
    rgxiao  
    OP
       Jun 19, 2024
    @cosette rsshub 订阅会有延迟吗?
    cosette
        12
    cosette  
       Jun 19, 2024
    @rgxiao rss 是定时拉取消息,肯定有延迟,不适合做实时监控。
    julyclyde
        13
    julyclyde  
       Jun 24, 2024
    Telethon
    iter_messages
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   903 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 47ms · UTC 20:18 · PVG 04:18 · LAX 13:18 · JFK 16:18
    ♥ Do have faith in what you're doing.