Files
dickbot/src/controllers/adminMessageController.go
2025-11-21 15:49:10 +03:00

47 lines
950 B
Go
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
package controllers
import (
"fmt"
"log"
"strings"
tele "gopkg.in/telebot.v4"
)
type AdminMessageController struct {
DC *DataController
Bot *tele.Bot
}
func NewAdminMessageController(b *tele.Bot, db *DataController) *AdminMessageController {
return &AdminMessageController{DC: db, Bot: b}
}
func (b *AdminMessageController) AdminMessage(c tele.Context) error {
var text string
chatId := c.Chat().ID
user := b.DC.GetUser(c.Sender().ID, chatId)
if !user.Admin {
return c.Send("У вас нет прав для использования этой команды")
}
if strings.Contains(c.Text(), " ") {
text = strings.Split(c.Text(), " ")[1]
fmt.Println("New admin message", text)
} else {
return c.Send("Некоректная команда, /ms <сообщение>")
}
_, err := b.Bot.Send(
c.Chat(),
text,
)
if err != nil {
log.Println(err)
}
return c.Send("Сообщение отправлено.")
}