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

View File

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