Compare commits

..

2 Commits

Author SHA1 Message Date
nefrace bb0862ba8b fix 2 2023-02-14 11:17:01 +03:00
nefrace 1c4a0adb61 Fixed NewBot 2023-02-14 11:16:17 +03:00
1 changed files with 11 additions and 8 deletions

View File

@ -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{
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.GetOne(ctx, tongo.E("chat_id", chatID)); err != nil {
if _, err := store.InsertOne(ctx, &chat); err != nil {
if _, err := store.InsertOne(ctx, chat); err != nil {
return &bot{}
}
}
@ -73,6 +75,7 @@ func (b *Kicker) NewBot(chatID int64) echotron.Bot {
nil,
echotron.NewAPI(b.Token),
}
log.Println("New bot created with CaptchaTopic", result.CaptchaTopic)
me, err := result.GetMe()
if err != nil {
log.Println(err)