smm_tg/internal/services/bot/bot_ping/bot.go

36 lines
607 B
Go
Raw Permalink Normal View History

2024-11-11 19:32:06 +00:00
package bot_ping
import (
"context"
"strings"
"git.3crabs.ru/save_my_money/smm_tg/internal/modules/messenger"
"git.3crabs.ru/save_my_money/smm_tg/internal/services/bot"
)
type botPing struct {
messenger messenger.IMessenger
}
func NewBotPing(
messenger messenger.IMessenger,
) bot.IBot {
return &botPing{
messenger: messenger,
}
}
func (bot *botPing) Process(ctx context.Context, msg *messenger.Message) error {
if !strings.Contains(msg.Text, "/ping") {
return nil
}
bot.messenger.SendMessage(
ctx,
&messenger.Message{
ChatID: msg.ChatID,
Text: "pong",
},
)
return nil
}