From 7fba6ddb93c580fc603e9910866da28b28c8ec0d Mon Sep 17 00:00:00 2001 From: nefrace Date: Tue, 14 Feb 2023 01:15:00 +0300 Subject: [PATCH] Fixed NewBot routine --- kicker/kicker.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/kicker/kicker.go b/kicker/kicker.go index 915d074..a2c2906 100644 --- a/kicker/kicker.go +++ b/kicker/kicker.go @@ -52,20 +52,20 @@ type Kicker struct { } func (b *Kicker) NewBot(chatID int64) echotron.Bot { - d := db.GetDatabase() + store := tongo.NewStore[db.Chat](Client) ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second) defer cancel() chat := db.Chat{ + Item: tongo.NewID(), ChatId: chatID, Title: "", TopicId: 0, } - if !d.ChatExists(ctx, chat) { - if err := d.NewChat(ctx, chat); err != nil { + if _, err := store.GetOne(ctx, tongo.E("chat_id", chatID)); err != nil { + if _, err := store.InsertOne(ctx, &chat); err != nil { return &bot{} } } - chat, _ = d.GetChat(ctx, chatID) CaptchaTopic := chat.TopicId result := &bot{ chatID,