This commit is contained in:
xeon 2026-08-21 23:53:17 +03:00
commit 973c19f148
7 changed files with 95 additions and 0 deletions

35
internal/bot/bot.go Normal file
View file

@ -0,0 +1,35 @@
package bot
import (
"context"
"log"
"spambot/internal/commands"
"spambot/internal/config"
"github.com/go-telegram/bot"
)
type TelegramBot struct {
config *config.Config
bot *bot.Bot
ctx context.Context
}
func NewTelegramBot(config *config.Config) *TelegramBot {
b, err := bot.New(config.Token)
b.RegisterHandler(bot.HandlerTypeMessageText, "/start", bot.MatchTypeExact, commands.StartCommand)
if err != nil {
log.Fatalf("Failed to create bot: %v", err)
}
return &TelegramBot{
config: config,
bot: b,
ctx: context.Background(),
}
}
func (b *TelegramBot) Start() {
b.bot.Start(b.ctx)
}