go-telegram-bot-api / telegram-bot-api

Golang bindings for the Telegram Bot API
https://go-telegram-bot-api.dev
MIT License
5.62k stars 868 forks source link

feat: add IsTextMention to MessageEntity #575

Closed niuhuan closed 1 year ago

niuhuan commented 1 year ago

This works when we tag a member without a username, It is different from a mention.

for _, entity := range message.Entities {
    if entity.IsTextMention() {
        println(entity.User.ID)
    }
    if entity.IsMention() {
        println(message.Text[entity.Offset:entity.Offset+entity.Length])
    }
}