Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

修复图片解析,添加 at 在 Telegram 的支持 #10

Merged
merged 4 commits into from
Jan 24, 2024

Conversation

Liki4
Copy link
Contributor

@Liki4 Liki4 commented Jan 24, 2024

修改了 index.ts 中的 image 元素和 url 属性,现在可以获取发送的图片了

Snipaste_2024-01-24_15-07-50

在 utils.ts 的 getAvatarUrlFromID 中添加了 telegram 的支持,因为要调用 getUser 所以改成了 async,相应在 index.ts 也加了 await

image

但是当被 at 的人有 username 时解析会失效,没仔细看是什么原因

Snipaste_2024-01-24_15-07-04

@Liki4
Copy link
Contributor Author

Liki4 commented Jan 24, 2024

在 satori 里有个 TODO
https://github.com/satorijs/satori/blob/master/adapters/telegram/src/utils.ts#L125

        if (eText === '@' + bot.user.name) {
          segs.push(h('at', { id: bot.user.id, name: atName }))
        } else {
          // TODO handle @others
          segs.push(h('text', { content: eText }))
        }

有 username 的时候 type 是 mention,但 user 字段是 text_mention only 的,所以只有 username 取不到 id...

{
    ......
            "entities": [
                {
                    "offset": 17,
                    "length": 11,
                    "type": "mention"
                }
            ]
    ......
}

image
没想到捣鼓到最后是 telegram 本身不支持这么做
https://core.telegram.org/bots/api#messageentity

@lgc2333
Copy link
Member

lgc2333 commented Jan 24, 2024

感谢贡献,最近一段时间我都在摸鱼,摆了

@lgc2333 lgc2333 merged commit 086b695 into lgc-KoiDev:master Jan 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants