Change project structure a bit

This commit is contained in:
2025-06-02 21:00:50 +03:00
parent 035045ce90
commit b1c34f77ce
7 changed files with 20 additions and 14 deletions
@@ -14,11 +14,11 @@ var fieldMap = logrus.FieldMap{
}
type Logger interface {
WithField(key string, value interface{}) Logger
WithField(key string, value any) Logger
Info(...interface{})
Error(error, ...interface{})
FatalError(error, ...interface{})
Info(...any)
Error(error, ...any)
FatalError(error, ...any)
}
type Config struct {
@@ -42,14 +42,14 @@ type logger struct {
logrus.FieldLogger
}
func (l *logger) WithField(key string, value interface{}) Logger {
func (l *logger) WithField(key string, value any) Logger {
return &logger{l.FieldLogger.WithField(key, value)}
}
func (l *logger) Error(err error, args ...interface{}) {
l.FieldLogger.WithError(err).Error(args)
func (l *logger) Error(err error, args ...any) {
l.FieldLogger.WithError(err).Error(args...)
}
func (l *logger) FatalError(err error, args ...interface{}) {
func (l *logger) FatalError(err error, args ...any) {
l.FieldLogger.WithError(err).Fatal(args...)
}
@@ -2,8 +2,9 @@ package handler
import (
"context"
"fmt"
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/jsonlog"
"github.com/nightnoryu/anon3anon/pkg/infrastructure/jsonlog"
"github.com/go-telegram/bot"
"github.com/go-telegram/bot/models"
@@ -15,6 +16,11 @@ func NewAnonymousMessagesHandler(logger jsonlog.Logger, ownerChatId int) bot.Han
return
}
if ownerChatId == 0 {
logger.Info(fmt.Sprintf("owner chat ID not set. set to %d to use the last chat", update.Message.Chat.ID))
return
}
params := &bot.CopyMessageParams{
ChatID: ownerChatId,
FromChatID: update.Message.Chat.ID,
@@ -3,7 +3,7 @@ package handler
import (
"context"
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/jsonlog"
"github.com/nightnoryu/anon3anon/pkg/infrastructure/jsonlog"
"github.com/go-telegram/bot"
"github.com/go-telegram/bot/models"
@@ -4,7 +4,7 @@ import (
"context"
"fmt"
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/jsonlog"
"github.com/nightnoryu/anon3anon/pkg/infrastructure/jsonlog"
"github.com/go-telegram/bot"
"github.com/go-telegram/bot/models"