Refactoring
1. Move all pre-defined messages to constants in a separate file 2. Remove pkg/errors dependency
This commit is contained in:
+2
-2
@@ -3,7 +3,7 @@ package handler
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/nightnoryu/anon3anon/pkg/infrastructure/jsonlog"
|
||||
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/jsonlog"
|
||||
|
||||
"github.com/go-telegram/bot"
|
||||
"github.com/go-telegram/bot/models"
|
||||
@@ -28,7 +28,7 @@ func NewAnonymousMessagesHandler(logger jsonlog.Logger, ownerChatId int) bot.Han
|
||||
|
||||
sendParams := &bot.SendMessageParams{
|
||||
ChatID: update.Message.Chat.ID,
|
||||
Text: "Сообщение отправлено!!",
|
||||
Text: messageSentMessage,
|
||||
}
|
||||
_, err = b.SendMessage(ctx, sendParams)
|
||||
if err != nil {
|
||||
@@ -0,0 +1,6 @@
|
||||
package handler
|
||||
|
||||
const (
|
||||
greetingMessage = "Жду твоих сообщений!!"
|
||||
messageSentMessage = "Сообщение отправлено!!"
|
||||
)
|
||||
+6
-2
@@ -3,7 +3,7 @@ package handler
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/nightnoryu/anon3anon/pkg/infrastructure/jsonlog"
|
||||
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/jsonlog"
|
||||
|
||||
"github.com/go-telegram/bot"
|
||||
"github.com/go-telegram/bot/models"
|
||||
@@ -11,9 +11,13 @@ import (
|
||||
|
||||
func NewStartCommandHandler(logger jsonlog.Logger) bot.HandlerFunc {
|
||||
return func(ctx context.Context, b *bot.Bot, update *models.Update) {
|
||||
if update.Message == nil {
|
||||
return
|
||||
}
|
||||
|
||||
params := &bot.SendMessageParams{
|
||||
ChatID: update.Message.Chat.ID,
|
||||
Text: "Жду твоих сообщений!!",
|
||||
Text: greetingMessage,
|
||||
}
|
||||
_, err := b.SendMessage(ctx, params)
|
||||
if err != nil {
|
||||
+1
-1
@@ -4,7 +4,7 @@ import (
|
||||
"context"
|
||||
"fmt"
|
||||
|
||||
"github.com/nightnoryu/anon3anon/pkg/infrastructure/jsonlog"
|
||||
"github.com/nightnoryu/anon3anon/pkg/anon3anon/infrastructure/jsonlog"
|
||||
|
||||
"github.com/go-telegram/bot"
|
||||
"github.com/go-telegram/bot/models"
|
||||
Reference in New Issue
Block a user