From 50d3f934656f1d83b7ea28b333b62128962c57b3 Mon Sep 17 00:00:00 2001 From: Vlad Rud Date: Tue, 7 Dec 2021 00:36:29 +0300 Subject: [PATCH] Fixed handlers, added debugging methods --- kicker/handlers.go | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/kicker/handlers.go b/kicker/handlers.go index 2b0abc5..f33b02e 100644 --- a/kicker/handlers.go +++ b/kicker/handlers.go @@ -2,6 +2,7 @@ package kicker import ( "context" + "fmt" "kickerbot/db" "log" "time" @@ -9,6 +10,24 @@ import ( 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{ // { // Endpoint: tb.OnText, @@ -39,8 +58,12 @@ var HandlersV1 = []Handler{ { Endpoint: tb.OnText, Handler: func(c tb.Context) error { - c.Bot().Send(&tb.User{ID: 60441930}, c.Message().Text) + db.Log("message") return nil }, }, + { + Endpoint: tb.OnUserJoined, + Handler: userJoined, + }, }