diff --git a/commands/command.go b/commands/command.go new file mode 100644 index 0000000..05cdddb --- /dev/null +++ b/commands/command.go @@ -0,0 +1,8 @@ +package commands + +type Command string + +const ( + Start = Command("/start") + Ping = Command("/ping") +) diff --git a/main.go b/main.go index 78b1dde..a1cdebc 100644 --- a/main.go +++ b/main.go @@ -2,6 +2,7 @@ package main import ( "errors" + "git.user-penguin.space/vladimir/all_tg_bot/commands" tgbot "github.com/go-telegram-bot-api/telegram-bot-api" "github.com/umputun/go-flags" "log" @@ -16,6 +17,7 @@ const ( type Opts struct { Token string `short:"t" long:"token" description:"Telegram api token"` + Name string `short:"n" long:"name" description:"Telegram bot name" default:"@butler_tg_bot"` } var opts Opts @@ -59,5 +61,13 @@ func run() { if strings.Contains(strings.ToLower(text), tag) { _, _ = bot.Send(tgbot.NewMessage(chatID, allUsers)) } + + command := commands.Command(strings.Replace(text, opts.Name, "", 1)) + switch command { + case commands.Start: + _, _ = bot.Send(tgbot.NewMessage(chatID, "Здравствуйте, я ваш дворецкий.")) + case commands.Ping: + _, _ = bot.Send(tgbot.NewMessage(chatID, "pong")) + } } }