Some renames
This commit is contained in:
parent
9744337c99
commit
8e06d4c1c9
|
@ -1,4 +1,4 @@
|
|||
package bot
|
||||
package kicker
|
||||
|
||||
import (
|
||||
tb "gopkg.in/tucnak/telebot.v3"
|
|
@ -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)
|
|
@ -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()
|
||||
}
|
Loading…
Reference in New Issue