telebot icon indicating copy to clipboard operation
telebot copied to clipboard

Can't handle message of type "any"

Open Dominux opened this issue 2 years ago • 0 comments

I wanna write one of my handlers to get specific messages from users. But their type may be any! And going through the docs didn't help me at all, it's misserable!

Even tho I decided to go to see how Bot.Handle works, and if there any wildcard implementation out there, but found only this function:

func (b *Bot) Handle(endpoint interface{}, h HandlerFunc, m ...MiddlewareFunc) {
	if len(b.group.middleware) > 0 {
		m = append(b.group.middleware, m...)
	}

	handler := func(c Context) error {
		return applyMiddleware(h, m...)(c)
	}

	switch end := endpoint.(type) {
	case string:
		b.handlers[end] = handler
	case CallbackEndpoint:
		b.handlers[end.CallbackUnique()] = handler
	default:
		panic("telebot: unsupported endpoint")
	}
}

As I can see, there's no any way to implement it.

Hope I'm wrong, cause it's really the place where there's the problem of any amateur framework with so bad architecture. The problem is that a framework cuts off some low level functional from a developer by making so high-level abstraction

Dominux avatar May 22 '22 19:05 Dominux