diff --git a/kicker/kicker.go b/kicker/kicker.go index a2c2906..385930e 100644 --- a/kicker/kicker.go +++ b/kicker/kicker.go @@ -55,14 +55,16 @@ func (b *Kicker) NewBot(chatID int64) echotron.Bot { 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 _, err := store.GetOne(ctx, tongo.E("chat_id", chatID)); err != nil { - if _, err := store.InsertOne(ctx, &chat); err != nil { + + chat, err := store.GetOne(ctx, tongo.E("chat_id", chatID)) + if err != nil { + chat = &db.Chat{ + Item: tongo.NewID(), + ChatId: chatID, + Title: "", + TopicId: 0, + } + if _, err := store.InsertOne(ctx, chat); err != nil { return &bot{} } }