Refactoring

1. Move all pre-defined messages to constants in a separate file
2. Remove pkg/errors dependency
This commit is contained in:
2025-05-15 22:20:37 +03:00
parent 0a8409e66d
commit 9e38b000ec
10 changed files with 34 additions and 20 deletions
@@ -1,38 +0,0 @@
package handler
import (
"context"
"github.com/nightnoryu/anon3anon/pkg/infrastructure/jsonlog"
"github.com/go-telegram/bot"
"github.com/go-telegram/bot/models"
)
func NewAnonymousMessagesHandler(logger jsonlog.Logger, ownerChatId int) bot.HandlerFunc {
return func(ctx context.Context, b *bot.Bot, update *models.Update) {
if update.Message == nil {
return
}
params := &bot.CopyMessageParams{
ChatID: ownerChatId,
FromChatID: update.Message.Chat.ID,
MessageID: update.Message.ID,
}
_, err := b.CopyMessage(ctx, params)
if err != nil {
logger.Error(err)
return
}
sendParams := &bot.SendMessageParams{
ChatID: update.Message.Chat.ID,
Text: "Сообщение отправлено!!",
}
_, err = b.SendMessage(ctx, sendParams)
if err != nil {
logger.Error(err)
}
}
}