Fixed NewBot routine

This commit is contained in:
nefrace 2023-02-14 01:15:00 +03:00
parent 765be0673b
commit 7fba6ddb93
1 changed files with 4 additions and 4 deletions

View File

@ -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,