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)
|
b.DeleteMessage(message.Chat.ID, message.ID)
|
||||||
text := fmt.Sprintf("*[%s](tg://user?id=%d)*, сначала пройди капчу\\!", user.FirstName, user.UserId)
|
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})
|
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
|
return nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,15 +136,20 @@ func checkCaptcha(b *bot, update *echotron.Update) error {
|
||||||
|
|
||||||
func botAdded(b *bot, update *echotron.Update) error {
|
func botAdded(b *bot, update *echotron.Update) error {
|
||||||
m := update.Message
|
m := update.Message
|
||||||
chat := db.Chat{
|
store := tongo.NewStore[db.Chat](Client)
|
||||||
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
||||||
|
defer cancel()
|
||||||
|
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,
|
ChatId: m.Chat.ID,
|
||||||
Title: m.Chat.Title,
|
Title: m.Chat.Title,
|
||||||
TopicId: 0,
|
TopicId: 0,
|
||||||
}
|
}
|
||||||
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
}
|
||||||
defer cancel()
|
|
||||||
d := db.GetDatabase()
|
_, err = store.InsertOne(ctx, chat)
|
||||||
err := d.NewChat(ctx, chat)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Print(err)
|
log.Print(err)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue