Fixed botAdded
This commit is contained in:
parent
23d4e9893e
commit
75454a3233
|
@ -91,7 +91,7 @@ func checkCaptcha(b *bot, update *echotron.Update) error {
|
|||
b.DeleteMessage(message.Chat.ID, message.ID)
|
||||
text := fmt.Sprintf("*[%s](tg://user?id=%d)*, сначала пройди капчу\\!", user.FirstName, user.UserId)
|
||||
res, _ := b.SendMessage(text, message.Chat.ID, &echotron.MessageOptions{ParseMode: echotron.MarkdownV2, MessageThreadID: message.ThreadID})
|
||||
go waitAndDelete(&b.API, res.Result, 30*time.Second)
|
||||
go waitAndDelete(&b.API, res.Result, 10*time.Second)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
@ -136,15 +136,20 @@ func checkCaptcha(b *bot, update *echotron.Update) error {
|
|||
|
||||
func botAdded(b *bot, update *echotron.Update) error {
|
||||
m := update.Message
|
||||
chat := db.Chat{
|
||||
ChatId: m.Chat.ID,
|
||||
Title: m.Chat.Title,
|
||||
TopicId: 0,
|
||||
}
|
||||
store := tongo.NewStore[db.Chat](Client)
|
||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||
defer cancel()
|
||||
d := db.GetDatabase()
|
||||
err := d.NewChat(ctx, chat)
|
||||
chat, err := store.GetOne(ctx, tongo.E("chat_id", m.Chat.ID))
|
||||
if err != nil {
|
||||
chat = &db.Chat{
|
||||
Item: tongo.NewID(),
|
||||
ChatId: m.Chat.ID,
|
||||
Title: m.Chat.Title,
|
||||
TopicId: 0,
|
||||
}
|
||||
}
|
||||
|
||||
_, err = store.InsertOne(ctx, chat)
|
||||
if err != nil {
|
||||
log.Print(err)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue