butler/internal/services/bot/bot_ping/bot.go

36 lines
597 B
Go

package bot_ping
import (
"context"
"strings"
"git.3crabs.ru/VLADIMIR/butler/internal/modules/messenger"
"git.3crabs.ru/VLADIMIR/butler/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
}