add new all command

This commit is contained in:
2022-04-25 03:07:52 +07:00
parent 42f73f84fd
commit 3e0bfc433b
2 changed files with 29 additions and 9 deletions
+6 -8
View File
@@ -13,10 +13,7 @@ import (
"strings"
)
const (
tag = "@all"
allUsers = "@vo13crabs @disconecto @v9gel @KeyM_v2 @k_ukolov @iamembarrassed @freel_Fedorov_Kirill @butinmv"
)
const tag = "@all"
type Opts struct {
Token string `short:"t" long:"token" description:"Telegram api token"`
@@ -82,21 +79,22 @@ func run() {
chatID := update.Message.Chat.ID
username := update.Message.From.UserName
_ = db.AddUserInChat(chatID, username)
if strings.Contains(strings.ToLower(text), tag) {
_, _ = bot.Send(tgbot.NewMessage(chatID, allUsers))
users, _ := db.GetUsers(chatID)
_, _ = bot.Send(tgbot.NewMessage(chatID, "@"+strings.Join(users, " @")))
}
command := commands.Command(strings.Replace(text, opts.Name, "", 1))
switch command {
case commands.Start:
_, _ = bot.Send(tgbot.NewMessage(chatID, fmt.Sprintf("Здравствуйте, я Волтер (v1.1.0), ваш дворецкий (%d).", chatID)))
_, _ = bot.Send(tgbot.NewMessage(chatID, fmt.Sprintf("Здравствуйте, я Волтер (v1.2.0), ваш дворецкий (%d).", chatID)))
_ = db.AddChat(chatID)
case commands.Help:
_, _ = bot.Send(tgbot.NewMessage(chatID, "Вот что я умею:\n\n1) Позвать всех"))
case commands.Ping:
_, _ = bot.Send(tgbot.NewMessage(chatID, "pong"))
}
_ = db.AddUserInChat(chatID, username)
}
}