Change project structure a bit
This commit is contained in:
@@ -5,9 +5,9 @@ import (
|
|||||||
"os"
|
"os"
|
||||||
"os/signal"
|
"os/signal"
|
||||||
|
|
||||||
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/jsonlog"
|
"github.com/nightnoryu/anon3anon/pkg/infrastructure/jsonlog"
|
||||||
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/telegram/handler"
|
"github.com/nightnoryu/anon3anon/pkg/infrastructure/telegram/handler"
|
||||||
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/telegram/middleware"
|
"github.com/nightnoryu/anon3anon/pkg/infrastructure/telegram/middleware"
|
||||||
|
|
||||||
"github.com/go-telegram/bot"
|
"github.com/go-telegram/bot"
|
||||||
)
|
)
|
||||||
|
|||||||
+8
-8
@@ -14,11 +14,11 @@ var fieldMap = logrus.FieldMap{
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Logger interface {
|
type Logger interface {
|
||||||
WithField(key string, value interface{}) Logger
|
WithField(key string, value any) Logger
|
||||||
|
|
||||||
Info(...interface{})
|
Info(...any)
|
||||||
Error(error, ...interface{})
|
Error(error, ...any)
|
||||||
FatalError(error, ...interface{})
|
FatalError(error, ...any)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
@@ -42,14 +42,14 @@ type logger struct {
|
|||||||
logrus.FieldLogger
|
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)}
|
return &logger{l.FieldLogger.WithField(key, value)}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (l *logger) Error(err error, args ...interface{}) {
|
func (l *logger) Error(err error, args ...any) {
|
||||||
l.FieldLogger.WithError(err).Error(args)
|
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...)
|
l.FieldLogger.WithError(err).Fatal(args...)
|
||||||
}
|
}
|
||||||
+7
-1
@@ -2,8 +2,9 @@ package handler
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"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"
|
||||||
"github.com/go-telegram/bot/models"
|
"github.com/go-telegram/bot/models"
|
||||||
@@ -15,6 +16,11 @@ func NewAnonymousMessagesHandler(logger jsonlog.Logger, ownerChatId int) bot.Han
|
|||||||
return
|
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{
|
params := &bot.CopyMessageParams{
|
||||||
ChatID: ownerChatId,
|
ChatID: ownerChatId,
|
||||||
FromChatID: update.Message.Chat.ID,
|
FromChatID: update.Message.Chat.ID,
|
||||||
+1
-1
@@ -3,7 +3,7 @@ package handler
|
|||||||
import (
|
import (
|
||||||
"context"
|
"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"
|
||||||
"github.com/go-telegram/bot/models"
|
"github.com/go-telegram/bot/models"
|
||||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"fmt"
|
"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"
|
||||||
"github.com/go-telegram/bot/models"
|
"github.com/go-telegram/bot/models"
|
||||||
Reference in New Issue
Block a user