From 9d5b5c2a2f46234f3efc2abfab19ec76ea5f155f 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 02:57:53 +0700 Subject: [PATCH] add AddUserInChat --- db/db.go | 4 ++-- main.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/db/db.go b/db/db.go index 3879cd7..13b6ca3 100644 --- a/db/db.go +++ b/db/db.go @@ -30,7 +30,7 @@ func AddChat(chatID int64) error { collection := client.Database(cfg.DBName).Collection(cfg.ChatsCollectionName) - result := collection.FindOne(ctx, bson.E{Key: "chat_id", Value: chatID}) + result := collection.FindOne(ctx, bson.M{"chat_id": chatID}) if result.Err() == mongo.ErrNoDocuments { if _, err := collection.InsertOne(ctx, &chatDTO{ChatID: chatID}); err != nil { return err @@ -56,7 +56,7 @@ func AddUserInChat(chatID int64, username string) error { collection := client.Database(cfg.DBName).Collection(cfg.ChatsCollectionName) _, err = collection.UpdateOne( ctx, - bson.E{Key: "chat_id", Value: chatID}, + bson.M{"chat_id": chatID}, bson.M{"addToSet": bson.M{"users": username}}, ) return err diff --git a/main.go b/main.go index 1004cc2..469b960 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.0.2), ваш дворецкий (%d).", chatID))) + _, _ = bot.Send(tgbot.NewMessage(chatID, fmt.Sprintf("Здравствуйте, я Волтер (v1.1.0), ваш дворецкий (%d).", chatID))) _ = db.AddChat(chatID) case commands.Help: _, _ = bot.Send(tgbot.NewMessage(chatID, "Вот что я умею:\n\n1) Позвать всех"))