diff --git a/go.mod b/go.mod index e05765b..7148e7e 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module godotkicker +module kickerbot go 1.17 diff --git a/bot/handlers.go b/kicker/handlers.go similarity index 93% rename from bot/handlers.go rename to kicker/handlers.go index b6fb441..308bd1d 100644 --- a/bot/handlers.go +++ b/kicker/handlers.go @@ -1,4 +1,4 @@ -package bot +package kicker import ( tb "gopkg.in/tucnak/telebot.v3" diff --git a/bot/bot.go b/kicker/kicker.go similarity index 73% rename from bot/bot.go rename to kicker/kicker.go index a83987e..62790b5 100644 --- a/bot/bot.go +++ b/kicker/kicker.go @@ -1,4 +1,4 @@ -package bot +package kicker import ( "errors" @@ -13,12 +13,14 @@ type Handler struct { Handler tb.HandlerFunc } -type Bot struct { +/// Базовая структура для бота +type Kicker struct { Bot *tb.Bot Token string } -func (b *Bot) Init() error { +/// Initialize bot with token +func (b *Kicker) Init() error { bot, err := tb.NewBot(tb.Settings{ Token: b.Token, Poller: &tb.LongPoller{Timeout: 10 * time.Second}, @@ -32,7 +34,7 @@ func (b *Bot) Init() error { } // Add handler methods to the bot -func (b *Bot) AddHandlers(handlers []Handler) error { +func (b *Kicker) AddHandlers(handlers []Handler) error { if len(handlers) != 0 { for i := range handlers { b.Bot.Handle(handlers[i].Endpoint, handlers[i].Handler) diff --git a/kicker.go b/main.go similarity index 60% rename from kicker.go rename to main.go index 3079a00..ddb25b2 100644 --- a/kicker.go +++ b/main.go @@ -4,7 +4,7 @@ import ( "log" "os" - "godotkicker/bot" + "kickerbot/kicker" ) func main() { @@ -13,10 +13,8 @@ func main() { log.Fatal("no token specified") } - Bot := bot.Bot{Token: token} + Bot := kicker.Kicker{Token: token} Bot.Init() - Bot.AddHandlers(bot.HandlersV1) - - log.Print("successfuly launched") + Bot.AddHandlers(kicker.HandlersV1) Bot.Bot.Start() }