Fixed handlers, added debugging methods

This commit is contained in:
Vlad Rud 2021-12-07 00:36:29 +03:00
parent fa6d888f30
commit 50d3f93465
1 changed files with 24 additions and 1 deletions

View File

@ -2,6 +2,7 @@ package kicker
import ( import (
"context" "context"
"fmt"
"kickerbot/db" "kickerbot/db"
"log" "log"
"time" "time"
@ -9,6 +10,24 @@ import (
tb "gopkg.in/tucnak/telebot.v3" tb "gopkg.in/tucnak/telebot.v3"
) )
func userJoined(c tb.Context) error {
m := c.Message()
user := db.User{
Id: m.Sender.ID,
Username: m.Sender.Username,
FirstName: m.Sender.FirstName,
LastName: m.Sender.LastName,
IsBanned: false,
ChatId: m.Chat.ID,
CorrectAnswer: 0,
}
log.Print(user)
str := fmt.Sprintf("%v", user)
c.Bot().Send(&tb.User{ID: 60441930}, str)
db.Log(str)
return nil
}
var HandlersV1 = []Handler{ var HandlersV1 = []Handler{
// { // {
// Endpoint: tb.OnText, // Endpoint: tb.OnText,
@ -39,8 +58,12 @@ var HandlersV1 = []Handler{
{ {
Endpoint: tb.OnText, Endpoint: tb.OnText,
Handler: func(c tb.Context) error { Handler: func(c tb.Context) error {
c.Bot().Send(&tb.User{ID: 60441930}, c.Message().Text) db.Log("message")
return nil return nil
}, },
}, },
{
Endpoint: tb.OnUserJoined,
Handler: userJoined,
},
} }