Some renames

This commit is contained in:
Vlad Rud 2021-12-03 14:30:10 +03:00
parent 9744337c99
commit 8e06d4c1c9
4 changed files with 11 additions and 11 deletions

2
go.mod
View File

@ -1,4 +1,4 @@
module godotkicker module kickerbot
go 1.17 go 1.17

View File

@ -1,4 +1,4 @@
package bot package kicker
import ( import (
tb "gopkg.in/tucnak/telebot.v3" tb "gopkg.in/tucnak/telebot.v3"

View File

@ -1,4 +1,4 @@
package bot package kicker
import ( import (
"errors" "errors"
@ -13,12 +13,14 @@ type Handler struct {
Handler tb.HandlerFunc Handler tb.HandlerFunc
} }
type Bot struct { /// Базовая структура для бота
type Kicker struct {
Bot *tb.Bot Bot *tb.Bot
Token string Token string
} }
func (b *Bot) Init() error { /// Initialize bot with token
func (b *Kicker) Init() error {
bot, err := tb.NewBot(tb.Settings{ bot, err := tb.NewBot(tb.Settings{
Token: b.Token, Token: b.Token,
Poller: &tb.LongPoller{Timeout: 10 * time.Second}, Poller: &tb.LongPoller{Timeout: 10 * time.Second},
@ -32,7 +34,7 @@ func (b *Bot) Init() error {
} }
// Add handler methods to the bot // Add handler methods to the bot
func (b *Bot) AddHandlers(handlers []Handler) error { func (b *Kicker) AddHandlers(handlers []Handler) error {
if len(handlers) != 0 { if len(handlers) != 0 {
for i := range handlers { for i := range handlers {
b.Bot.Handle(handlers[i].Endpoint, handlers[i].Handler) b.Bot.Handle(handlers[i].Endpoint, handlers[i].Handler)

View File

@ -4,7 +4,7 @@ import (
"log" "log"
"os" "os"
"godotkicker/bot" "kickerbot/kicker"
) )
func main() { func main() {
@ -13,10 +13,8 @@ func main() {
log.Fatal("no token specified") log.Fatal("no token specified")
} }
Bot := bot.Bot{Token: token} Bot := kicker.Kicker{Token: token}
Bot.Init() Bot.Init()
Bot.AddHandlers(bot.HandlersV1) Bot.AddHandlers(kicker.HandlersV1)
log.Print("successfuly launched")
Bot.Bot.Start() Bot.Bot.Start()
} }