This commit is contained in:
SmileRex
2025-01-24 10:38:30 +03:00
parent c20348036d
commit 65350adcba
2 changed files with 13 additions and 13 deletions

View File

@@ -2,7 +2,6 @@ package main
import ( import (
"bot/src/controllers" "bot/src/controllers"
"bot/src/handlers"
"bot/src/models" "bot/src/models"
"log" "log"
"os" "os"
@@ -28,6 +27,7 @@ func config() models.Config {
return config return config
} }
func main() { func main() {
cfg := config() cfg := config()
pref := tele.Settings{ pref := tele.Settings{
@@ -42,11 +42,12 @@ func main() {
} }
dc := controllers.NewDB(cfg) dc := controllers.NewDB(cfg)
dataHandler := handlers.NewHandlers(dc)
dickController := controllers.NewDick(dc)
duelController := controllers.NewDuel(b, dc) duelController := controllers.NewDuel(b, dc)
b.Handle("/dick", dataHandler.Dick) b.Handle("/dick", dickController.Dick)
b.Handle("/top_dick", dataHandler.TopDick) b.Handle("/top_dick", dickController.TopDick)
b.Handle("/duel", duelController.StartMatch) b.Handle("/duel", duelController.StartMatch)
b.Handle("/accept", duelController.AcceptMatch) b.Handle("/accept", duelController.AcceptMatch)

View File

@@ -1,21 +1,20 @@
package handlers package controllers
import ( import (
"bot/src/controllers"
"fmt" "fmt"
tele "gopkg.in/telebot.v4" tele "gopkg.in/telebot.v4"
) )
type Handlers struct { type DickController struct {
DC *controllers.DataController DC *DataController
} }
func NewHandlers(db *controllers.DataController) *Handlers { func NewDick(db *DataController) *DickController {
return &Handlers{DC: db} return &DickController{DC: db}
} }
func (d *Handlers) Dick(c tele.Context) error { func (d *DickController) Dick(c tele.Context) error {
var retMessage string var retMessage string
id := c.Sender().ID id := c.Sender().ID
@@ -29,7 +28,7 @@ func (d *Handlers) Dick(c tele.Context) error {
user = d.DC.GetUser(id) user = d.DC.GetUser(id)
} }
newRange := controllers.RandRange() newRange := RandRange()
newSize := user.DickSize + newRange newSize := user.DickSize + newRange
if user.Blocked { if user.Blocked {
@@ -49,7 +48,7 @@ func (d *Handlers) Dick(c tele.Context) error {
return c.Send(retMessage) return c.Send(retMessage)
} }
func (d *Handlers) TopDick(c tele.Context) error { func (d *DickController) TopDick(c tele.Context) error {
var retMessage string var retMessage string
users := d.DC.GetTopUsers() users := d.DC.GetTopUsers()