go-telegram / bot

Telegram Bot API Go framework
MIT License
507 stars 46 forks source link

HandlerType for voice messages #17

Closed wmw-lv closed 1 year ago

wmw-lv commented 1 year ago

Do you consider adding HandlerTypeVoiceMessage to Types?

negasus commented 1 year ago

Hello. Custom handlers made for automatic text matching checks. For example, Update.Message.Text or Update.CallbackQuery.Data. Voice is a part of a Message. You can use this example

func main() {
    ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt)
    defer cancel()

    opts := []bot.Option{
        bot.WithDefaultHandler(handler),
    }

    b, _ := bot.New(os.Getenv("EXAMPLE_TELEGRAM_BOT_TOKEN"), opts...)
    b.Start(ctx)
}

func handler(ctx context.Context, b *bot.Bot, update *models.Update) {
    if update.Message != nil && update.Message.Voice != nil {
        // handle voice message
        return
    }
}

Will this solve your issue?

wmw-lv commented 1 year ago

Hello, thank you very much for your response. It wasn't quite an issue, it was a suggestion. And yes, your previous comment solve this for sure.