permission

package
v0.0.10 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 14, 2021 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

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")
)

Functions

This section is empty.

Types

type CommandOption

type CommandOption func(c *commandOption)

func ExpireOption

func ExpireOption(d time.Duration) CommandOption

type KeySet

type KeySet struct{}

func NewKeySet

func NewKeySet() *KeySet

func (*KeySet) BlockListKey

func (k *KeySet) BlockListKey(keys ...interface{}) string

func (*KeySet) GroupEnabledKey

func (k *KeySet) GroupEnabledKey(keys ...interface{}) string

func (*KeySet) GroupPermissionKey

func (k *KeySet) GroupPermissionKey(keys ...interface{}) string

func (*KeySet) PermissionKey

func (k *KeySet) PermissionKey(keys ...interface{}) string

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 RoleType

type RoleType int64
const (
	Unknown RoleType = 0

	Admin RoleType = 1 << iota
	GroupAdmin
)

func FromString

func FromString(s string) RoleType

func (RoleType) String

func (t RoleType) String() string

type StateManager

type StateManager struct {
	*localdb.ShortCut
	*KeySet
}

func NewStateManager

func NewStateManager() *StateManager

func (*StateManager) AddBlockList

func (c *StateManager) AddBlockList(caller int64, d time.Duration) error

func (*StateManager) CheckBlockList

func (c *StateManager) CheckBlockList(caller int64) bool

CheckBlockList return true if blocked

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 explicit disabled, must exist

func (*StateManager) CheckGroupCommandEnabled

func (c *StateManager) CheckGroupCommandEnabled(groupCode int64, command string) bool

CheckGroupCommandEnabled check explicit enabled, must exist

func (*StateManager) CheckGroupCommandFunc

func (c *StateManager) CheckGroupCommandFunc(groupCode int64, command string, f func(val string, exist bool) bool) bool

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) CheckRole

func (c *StateManager) CheckRole(caller int64, role RoleType) bool

func (*StateManager) DeleteBlockList

func (c *StateManager) DeleteBlockList(caller int64) error

func (*StateManager) DisableGroupCommand

func (c *StateManager) DisableGroupCommand(groupCode int64, command string, opts ...CommandOption) error

func (*StateManager) EnableGroupCommand

func (c *StateManager) EnableGroupCommand(groupCode int64, command string, opts ...CommandOption) error

func (*StateManager) FreshIndex

func (c *StateManager) FreshIndex()

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) RemoveAllByGroup

func (c *StateManager) RemoveAllByGroup(groupCode int64) error

func (*StateManager) RequireAny

func (c *StateManager) RequireAny(option ...RequireOption) bool

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL