group_helper/cli/commands/rules.go

49 lines
1.1 KiB
Go
Raw Normal View History

package commands
import (
"git.dragon-labs.de/alphyron/group_helper/cli"
"git.dragon-labs.de/alphyron/group_helper/logic"
"git.dragon-labs.de/alphyron/group_helper/models"
tgbotapi "github.com/go-telegram-bot-api/telegram-bot-api"
)
type rules struct {
groupHelperService logic.GroupHelperService
}
func NewRules(groupHelperService logic.GroupHelperService) cli.Command {
return &rules{
groupHelperService: groupHelperService,
}
}
func (r rules) GetUsage() string {
return "/rules"
}
func (r rules) GetCommand() string {
return "/rules"
}
func (r rules) GetDescription() string {
return "Get the rules of this group"
}
func (r rules) ExecuteCommand(api *tgbotapi.BotAPI, update *tgbotapi.Update, group *models.Group) (bool, error) {
msg := tgbotapi.NewMessage(update.Message.Chat.ID, group.Rules)
_, err := api.Send(msg)
return err != nil, err
}
func (r rules) AllowChatType(chat *tgbotapi.Chat) bool {
return true
}
func (r rules) AllowMember(member *tgbotapi.ChatMember) bool {
return true
}
func (r rules) AllowEveryMember() bool {
return true
}