44 lines
941 B
Go
44 lines
941 B
Go
package bot
|
|
|
|
import (
|
|
"context"
|
|
|
|
"git.iamglitch.cc/glitch/bookmate/internal/service"
|
|
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api/v5"
|
|
)
|
|
|
|
type Handler struct {
|
|
bot *tgbotapi.BotAPI
|
|
service *service.Service
|
|
}
|
|
|
|
func newHandler(bot *tgbotapi.BotAPI, svc *service.Service) *Handler {
|
|
return &Handler{
|
|
bot: bot,
|
|
service: svc,
|
|
}
|
|
}
|
|
|
|
func (h *Handler) HandleUpdate(ctx context.Context, update tgbotapi.Update) {
|
|
if update.Message != nil {
|
|
h.handleMessage(ctx, update.Message)
|
|
}
|
|
|
|
if update.CallbackQuery != nil {
|
|
h.handleCallback(ctx, update.CallbackQuery)
|
|
}
|
|
}
|
|
|
|
func (h *Handler) handleMessage(ctx context.Context, msg *tgbotapi.Message) {
|
|
if msg.IsCommand() {
|
|
h.handleCommand(ctx, msg)
|
|
}
|
|
}
|
|
|
|
func (h *Handler) handleCommand(ctx context.Context, msg *tgbotapi.Message) {
|
|
panic("unimplemented")
|
|
}
|
|
|
|
func (h *Handler) handleCallback(ctx context.Context, cb *tgbotapi.CallbackQuery) {
|
|
panic("unimplemented")
|
|
}
|