From 292888ce9c4924028a0f9285f0425fcd7c353596 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=92=D0=BB=D0=B0=D0=B4=D0=B8=D0=BC=D0=B8=D1=80=20=D0=A4?= =?UTF-8?q?=D0=B5=D0=B4=D0=BE=D1=80=D0=BE=D0=B2?= Date: Mon, 25 Apr 2022 03:11:23 +0700 Subject: [PATCH] fix new all command --- db/db.go | 10 +++++++--- main.go | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/db/db.go b/db/db.go index f351a70..9cb21aa 100644 --- a/db/db.go +++ b/db/db.go @@ -10,6 +10,10 @@ import ( ) type chatDTO struct { + ChatID int64 `bson:"chat_id"` +} + +type chatInfoDTO struct { ChatID int64 `bson:"chat_id"` Users []string `bson:"users"` } @@ -77,9 +81,9 @@ func GetUsers(chatID int64) ([]string, error) { } collection := client.Database(cfg.DBName).Collection(cfg.ChatsCollectionName) - chatDTO := &chatDTO{} - if err := collection.FindOne(ctx, bson.M{"chat_id": chatID}).Decode(chatDTO); err != nil { + chatInfoDTO := &chatInfoDTO{} + if err := collection.FindOne(ctx, bson.M{"chat_id": chatID}).Decode(chatInfoDTO); err != nil { return nil, err } - return chatDTO.Users, err + return chatInfoDTO.Users, err } diff --git a/main.go b/main.go index 6215709..08c5106 100644 --- a/main.go +++ b/main.go @@ -89,7 +89,7 @@ func run() { command := commands.Command(strings.Replace(text, opts.Name, "", 1)) switch command { case commands.Start: - _, _ = bot.Send(tgbot.NewMessage(chatID, fmt.Sprintf("Здравствуйте, я Волтер (v1.2.0), ваш дворецкий (%d).", chatID))) + _, _ = bot.Send(tgbot.NewMessage(chatID, fmt.Sprintf("Здравствуйте, я Волтер (v1.2.1), ваш дворецкий (%d).", chatID))) _ = db.AddChat(chatID) case commands.Help: _, _ = bot.Send(tgbot.NewMessage(chatID, "Вот что я умею:\n\n1) Позвать всех"))