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

36 lines
597 B
Go
Raw Permalink Normal View History

2023-09-13 19:20:02 +00:00
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
}