2021-12-03 14:30:10 +03:00
|
|
|
package kicker
|
2021-12-03 12:19:55 +03:00
|
|
|
|
|
|
|
import (
|
2021-12-06 11:46:11 +03:00
|
|
|
"context"
|
|
|
|
"kickerbot/db"
|
|
|
|
"log"
|
|
|
|
"time"
|
|
|
|
|
2021-12-03 12:19:55 +03:00
|
|
|
tb "gopkg.in/tucnak/telebot.v3"
|
|
|
|
)
|
|
|
|
|
|
|
|
var HandlersV1 = []Handler{
|
2021-12-06 11:46:11 +03:00
|
|
|
// {
|
|
|
|
// Endpoint: tb.OnText,
|
|
|
|
// Handler: func(c tb.Context) error {
|
|
|
|
// m := c.Message()
|
|
|
|
// c.Bot().Send(m.Sender, m.Text)
|
|
|
|
// return nil
|
|
|
|
// },
|
|
|
|
// },
|
2021-12-03 12:19:55 +03:00
|
|
|
{
|
2021-12-06 11:46:11 +03:00
|
|
|
Endpoint: tb.OnAddedToGroup,
|
2021-12-03 12:19:55 +03:00
|
|
|
Handler: func(c tb.Context) error {
|
|
|
|
m := c.Message()
|
2021-12-06 11:46:11 +03:00
|
|
|
chat := db.Chat{
|
|
|
|
Id: m.Chat.ID,
|
|
|
|
Title: m.Chat.Title,
|
|
|
|
}
|
|
|
|
ctx, cancel := context.WithTimeout(context.Background(), 10*time.Second)
|
|
|
|
defer cancel()
|
|
|
|
d := db.GetDatabase()
|
|
|
|
err := d.NewChat(ctx, chat)
|
|
|
|
if err != nil {
|
|
|
|
log.Print(err)
|
|
|
|
}
|
|
|
|
return nil
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
Endpoint: tb.OnText,
|
|
|
|
Handler: func(c tb.Context) error {
|
|
|
|
c.Bot().Send(&tb.User{ID: 60441930}, c.Message().Text)
|
2021-12-03 12:19:55 +03:00
|
|
|
return nil
|
|
|
|
},
|
|
|
|
},
|
|
|
|
}
|