Skip to content

Bug: Telegram 适配器无法正确读取消息中的 @ #1452

@Ikaleio

Description

@Ikaleio

Describe the bug

如果你使用以下指令尝试从 @ 中读取用户 id

ctx.command("test <user:user>")
    .action(async (_, userStr) => {
      ctx.logger('test').info(userStr)
    })

你会发现在 Telegram 适配器下你读了个寂寞
42006e7b1ee15705c980ffb8b846de30
a610b14559ee0584e6d3d12cad464dc5

以下是详细日志

2024-08-25 14:59:28 [D] telegram [response] { ok: true, result: [ { update_id: 561271410, message: { message_id: 425, from: { id: 5420165211, is_bot: false, first_name: 'd0j1a1701', username: 'd0j1a1701', language_code: 'zh-hans', is_premium: true }, chat: { id: -1002201482660, title: '「香草」测试群', type: 'supergroup' }, date: 1724569167, text: '/test @d0j1a1701', entities: [ { offset: 0, length: 5, type: 'bot_command' }, { offset: 6, length: 10, type: 'mention' } ] } } ] }
2024-08-25 14:59:28 [D] telegram receive {"update_id":561271410,"message":{"message_id":425,"from":{"id":5420165211,"is_bot":false,"first_name":"d0j1a1701","username":"d0j1a1701","language_code":"zh-hans","is_premium":true},"chat":{"id":-1002201482660,"title":"「香草」测试群","type":"supergroup"},"date":1724569167,"text":"/test @d0j1a1701","entities":[{"offset":0,"length":5,"type":"bot_command"},{"offset":6,"length":10,"type":"mention"}]}}
2024-08-25 14:59:28 [I] test telegram:undefined

可以看到一个巨大的 telegram:undefined 呈现在眼前。

Steps to reproduce

最小复现代码如上

Expected behavior

我们拿出接入 NapCat 的 onebot 适配器。

555cfcff766e95ff289781dec846c4e4

2024-08-25 15:01:10 [I] test onebot:30******26 // 被 @ 人的正确 QQ 号码。

Screenshots

No response

Versions

System:
OS: Linux 5.15 Ubuntu 22.04.4 LTS 22.04.4 LTS (Jammy Jellyfish)
CPU: (4) x64 AMD EPYC 7B13 64-Core Processor

Binaries:
Node: 21.7.3
Yarn: 4.1.1

Koishi:
Core: 4.17.12
Console: 5.29.3

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions