Documentation ¶
Index ¶
- Constants
- Variables
- func IsPermissionError(err error) bool
- type KeySet
- func (k *KeySet) BlockListKey(keys ...interface{}) string
- func (k *KeySet) GlobalEnabledKey(keys ...interface{}) string
- func (k *KeySet) GlobalSilenceKey(keys ...interface{}) string
- func (k *KeySet) GroupEnabledKey(keys ...interface{}) string
- func (k *KeySet) GroupPermissionKey(keys ...interface{}) string
- func (k *KeySet) GroupSilenceKey(keys ...interface{}) string
- func (k *KeySet) PermissionKey(keys ...interface{}) string
- type RequireOption
- type RoleType
- type StateManager
- func (c *StateManager) AddBlockList(caller int64, d time.Duration) error
- func (c *StateManager) CheckAdmin(caller int64) bool
- func (c *StateManager) CheckBlockList(caller int64) bool
- func (c *StateManager) CheckGlobalCommandDisabled(command string) bool
- func (c *StateManager) CheckGlobalCommandFunc(command string, f func(val string, exist bool) bool) bool
- func (c *StateManager) CheckGlobalSilence() bool
- func (c *StateManager) CheckGroupAdmin(groupCode int64, caller int64) bool
- func (c *StateManager) CheckGroupAdministrator(groupCode int64, caller int64) bool
- func (c *StateManager) CheckGroupCommandDisabled(groupCode int64, command string) bool
- func (c *StateManager) CheckGroupCommandEnabled(groupCode int64, command string) bool
- func (c *StateManager) CheckGroupCommandFunc(groupCode int64, command string, f func(val string, exist bool) bool) bool
- func (c *StateManager) CheckGroupCommandPermission(groupCode int64, caller int64, command string) bool
- func (c *StateManager) CheckGroupRole(groupCode int64, caller int64, role RoleType) bool
- func (c *StateManager) CheckGroupSilence(groupCode int64) bool
- func (c *StateManager) CheckNoAdmin() bool
- func (c *StateManager) CheckRole(caller int64, role RoleType) bool
- func (c *StateManager) DeleteBlockList(caller int64) error
- func (c *StateManager) DisableGroupCommand(groupCode int64, command string) error
- func (c *StateManager) EnableGroupCommand(groupCode int64, command string) error
- func (c *StateManager) FreshIndex()
- func (c *StateManager) GlobalDisableGroupCommand(command string) error
- func (c *StateManager) GlobalEnableGroupCommand(command string) error
- func (c *StateManager) GlobalSilence() error
- func (c *StateManager) GrantGroupRole(groupCode int64, target int64, role RoleType) error
- func (c *StateManager) GrantPermission(groupCode int64, target int64, command string) error
- func (c *StateManager) GrantRole(target int64, role RoleType) error
- func (c *StateManager) GroupSilence(groupCode int64) error
- func (c *StateManager) ListAdmin() []int64
- func (c *StateManager) ListGroupAdmin(groupCode int64) []int64
- func (c *StateManager) RemoveAllByGroupCode(groupCode int64) ([]string, error)
- func (c *StateManager) RequireAny(option ...RequireOption) bool
- func (c *StateManager) UndoGlobalSilence() error
- func (c *StateManager) UndoGroupSilence(groupCode int64) error
- func (c *StateManager) UngrantGroupRole(groupCode int64, target int64, role RoleType) error
- func (c *StateManager) UngrantPermission(groupCode int64, target int64, command string) error
- func (c *StateManager) UngrantRole(target int64, role RoleType) error
Constants ¶
View Source
const Disable = "disable"
View Source
const Enable = "enable"
Variables ¶
View Source
var ( ErrPermissionExist = errors.New("already exist") ErrPermissionNotExist = errors.New("not exist") ErrPermissionDenied = errors.New("permission denied") ErrDisabled = errors.New("disabled") ErrGlobalDisabled = errors.New("global disabled") ErrGlobalSilenced = errors.New("global silenced") )
Functions ¶
func IsPermissionError ¶ added in v0.0.13
Types ¶
type KeySet ¶
type KeySet struct{}
func (*KeySet) BlockListKey ¶
func (*KeySet) GlobalEnabledKey ¶ added in v0.0.16
func (*KeySet) GlobalSilenceKey ¶ added in v0.1.3
func (*KeySet) GroupEnabledKey ¶
func (*KeySet) GroupPermissionKey ¶
func (*KeySet) GroupSilenceKey ¶ added in v0.1.3
func (*KeySet) PermissionKey ¶
type RequireOption ¶
type RequireOption interface {
Validate(s *StateManager) bool
}
func AdminRoleRequireOption ¶
func AdminRoleRequireOption(uin int64) RequireOption
func GroupAdminRoleRequireOption ¶
func GroupAdminRoleRequireOption(groupCode int64, uin int64) RequireOption
func GroupCommandRequireOption ¶
func GroupCommandRequireOption(groupCode int64, uin int64, command string) RequireOption
func QQAdminRequireOption ¶
func QQAdminRequireOption(groupCode int64, uin int64) RequireOption
type StateManager ¶
func NewStateManager ¶
func NewStateManager() *StateManager
func (*StateManager) AddBlockList ¶
func (c *StateManager) AddBlockList(caller int64, d time.Duration) error
func (*StateManager) CheckAdmin ¶ added in v1.0.3
func (c *StateManager) CheckAdmin(caller int64) bool
func (*StateManager) CheckBlockList ¶
func (c *StateManager) CheckBlockList(caller int64) bool
CheckBlockList return true if blocked
func (*StateManager) CheckGlobalCommandDisabled ¶ added in v0.0.16
func (c *StateManager) CheckGlobalCommandDisabled(command string) bool
func (*StateManager) CheckGlobalCommandFunc ¶ added in v0.0.16
func (*StateManager) CheckGlobalSilence ¶ added in v0.1.3
func (c *StateManager) CheckGlobalSilence() bool
func (*StateManager) CheckGroupAdmin ¶ added in v1.0.3
func (c *StateManager) CheckGroupAdmin(groupCode int64, caller int64) bool
func (*StateManager) CheckGroupAdministrator ¶
func (c *StateManager) CheckGroupAdministrator(groupCode int64, caller int64) bool
func (*StateManager) CheckGroupCommandDisabled ¶
func (c *StateManager) CheckGroupCommandDisabled(groupCode int64, command string) bool
CheckGroupCommandDisabled check global first, then check explicit disabled, must exist
func (*StateManager) CheckGroupCommandEnabled ¶
func (c *StateManager) CheckGroupCommandEnabled(groupCode int64, command string) bool
CheckGroupCommandEnabled check global first, check explicit enabled, must exist
func (*StateManager) CheckGroupCommandFunc ¶
func (*StateManager) CheckGroupCommandPermission ¶
func (c *StateManager) CheckGroupCommandPermission(groupCode int64, caller int64, command string) bool
func (*StateManager) CheckGroupRole ¶
func (c *StateManager) CheckGroupRole(groupCode int64, caller int64, role RoleType) bool
func (*StateManager) CheckGroupSilence ¶ added in v0.1.3
func (c *StateManager) CheckGroupSilence(groupCode int64) bool
func (*StateManager) CheckNoAdmin ¶ added in v0.0.16
func (c *StateManager) CheckNoAdmin() bool
func (*StateManager) DeleteBlockList ¶
func (c *StateManager) DeleteBlockList(caller int64) error
func (*StateManager) DisableGroupCommand ¶
func (c *StateManager) DisableGroupCommand(groupCode int64, command string) error
func (*StateManager) EnableGroupCommand ¶
func (c *StateManager) EnableGroupCommand(groupCode int64, command string) error
func (*StateManager) FreshIndex ¶
func (c *StateManager) FreshIndex()
func (*StateManager) GlobalDisableGroupCommand ¶ added in v0.0.16
func (c *StateManager) GlobalDisableGroupCommand(command string) error
func (*StateManager) GlobalEnableGroupCommand ¶ added in v0.0.16
func (c *StateManager) GlobalEnableGroupCommand(command string) error
func (*StateManager) GlobalSilence ¶ added in v0.1.3
func (c *StateManager) GlobalSilence() error
func (*StateManager) GrantGroupRole ¶
func (c *StateManager) GrantGroupRole(groupCode int64, target int64, role RoleType) error
func (*StateManager) GrantPermission ¶
func (c *StateManager) GrantPermission(groupCode int64, target int64, command string) error
func (*StateManager) GrantRole ¶
func (c *StateManager) GrantRole(target int64, role RoleType) error
func (*StateManager) GroupSilence ¶ added in v0.1.3
func (c *StateManager) GroupSilence(groupCode int64) error
func (*StateManager) ListAdmin ¶ added in v0.1.3
func (c *StateManager) ListAdmin() []int64
func (*StateManager) ListGroupAdmin ¶ added in v1.0.4
func (c *StateManager) ListGroupAdmin(groupCode int64) []int64
func (*StateManager) RemoveAllByGroupCode ¶ added in v0.0.19
func (c *StateManager) RemoveAllByGroupCode(groupCode int64) ([]string, error)
func (*StateManager) RequireAny ¶
func (c *StateManager) RequireAny(option ...RequireOption) bool
func (*StateManager) UndoGlobalSilence ¶ added in v0.1.3
func (c *StateManager) UndoGlobalSilence() error
func (*StateManager) UndoGroupSilence ¶ added in v0.1.3
func (c *StateManager) UndoGroupSilence(groupCode int64) error
func (*StateManager) UngrantGroupRole ¶
func (c *StateManager) UngrantGroupRole(groupCode int64, target int64, role RoleType) error
func (*StateManager) UngrantPermission ¶
func (c *StateManager) UngrantPermission(groupCode int64, target int64, command string) error
func (*StateManager) UngrantRole ¶
func (c *StateManager) UngrantRole(target int64, role RoleType) error
Click to show internal directories.
Click to hide internal directories.