concern_manager

package
v0.1.4 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	FilterTypeType    = "type"
	FilterTypeNotType = "not_type"
	FilterTypeText    = "text"
)

Variables

View Source
var (
	ErrAlreadyExists  = errors.New("already exists")
	ErrLengthMismatch = errors.New("length mismatch")
)
View Source
var ErrEmitQNotInit = errors.New("emit queue not enabled")
View Source
var HookResultPass = &HookResult{
	Pass: true,
}

Functions

This section is empty.

Types

type AtSomeone added in v0.0.10

type AtSomeone struct {
	Ctype  concern.Type `json:"ctype"`
	AtList []int64      `json:"at_list"`
}

type Callback added in v0.0.20

type Callback interface {
	NotifyBeforeCallback(notify concern.Notify)
	NotifyAfterCallback(notify concern.Notify, message *message.GroupMessage)
}

type GroupConcernAtConfig added in v0.0.10

type GroupConcernAtConfig struct {
	AtAll     concern.Type `json:"at_all"`
	AtSomeone []*AtSomeone `json:"at_someone"`
}

GroupConcernAtConfig @配置

func (*GroupConcernAtConfig) CheckAtAll added in v0.0.10

func (g *GroupConcernAtConfig) CheckAtAll(ctype concern.Type) bool

func (*GroupConcernAtConfig) ClearAtSomeoneList added in v0.0.13

func (g *GroupConcernAtConfig) ClearAtSomeoneList(ctype concern.Type)

func (*GroupConcernAtConfig) GetAtSomeoneList added in v0.0.10

func (g *GroupConcernAtConfig) GetAtSomeoneList(ctype concern.Type) []int64

func (*GroupConcernAtConfig) MergeAtSomeoneList added in v0.0.13

func (g *GroupConcernAtConfig) MergeAtSomeoneList(ctype concern.Type, ids []int64)

func (*GroupConcernAtConfig) RemoveAtSomeoneList added in v0.0.13

func (g *GroupConcernAtConfig) RemoveAtSomeoneList(ctype concern.Type, ids []int64)

func (*GroupConcernAtConfig) SetAtSomeoneList added in v0.0.13

func (g *GroupConcernAtConfig) SetAtSomeoneList(ctype concern.Type, ids []int64)

type GroupConcernConfig added in v0.0.10

type GroupConcernConfig struct {
	GroupConcernAt     GroupConcernAtConfig     `json:"group_concern_at"`
	GroupConcernNotify GroupConcernNotifyConfig `json:"group_concern_notify"`
	GroupConcernFilter GroupConcernFilterConfig `json:"group_concern_filter"`
	// contains filtered or unexported fields
}

func NewGroupConcernConfigFromString added in v0.0.10

func NewGroupConcernConfigFromString(s string) (*GroupConcernConfig, error)

func (GroupConcernConfig) AtBeforeHook added in v0.0.13

func (d GroupConcernConfig) AtBeforeHook(notify concern.Notify) *HookResult

func (GroupConcernConfig) NewsFilterHook added in v0.0.14

func (d GroupConcernConfig) NewsFilterHook(notify concern.Notify) *HookResult

func (GroupConcernConfig) NotifyAfterCallback added in v0.0.20

func (d GroupConcernConfig) NotifyAfterCallback(notify concern.Notify, message *message.GroupMessage)

func (GroupConcernConfig) NotifyBeforeCallback added in v0.0.20

func (d GroupConcernConfig) NotifyBeforeCallback(notify concern.Notify)

func (GroupConcernConfig) ShouldSendHook added in v0.0.13

func (d GroupConcernConfig) ShouldSendHook(notify concern.Notify) *HookResult

func (*GroupConcernConfig) ToString added in v0.0.10

func (g *GroupConcernConfig) ToString() string

type GroupConcernFilterConfig added in v0.0.14

type GroupConcernFilterConfig struct {
	Type   string `json:"type"`
	Config string `json:"config"`
}

GroupConcernFilterConfig 过滤器配置

func (*GroupConcernFilterConfig) Empty added in v0.0.14

func (g *GroupConcernFilterConfig) Empty() bool

func (*GroupConcernFilterConfig) GetFilterByText added in v0.0.14

func (*GroupConcernFilterConfig) GetFilterByType added in v0.0.14

type GroupConcernFilterConfigByText added in v0.0.14

type GroupConcernFilterConfigByText struct {
	Text []string `json:"text"`
}

func (*GroupConcernFilterConfigByText) ToString added in v0.0.14

func (g *GroupConcernFilterConfigByText) ToString() string

type GroupConcernFilterConfigByType added in v0.0.14

type GroupConcernFilterConfigByType struct {
	Type []string `json:"type"`
}

func (*GroupConcernFilterConfigByType) ToString added in v0.0.14

func (g *GroupConcernFilterConfigByType) ToString() string

type GroupConcernNotifyConfig added in v0.0.13

type GroupConcernNotifyConfig struct {
	TitleChangeNotify concern.Type `json:"title_change_notify"`
	OfflineNotify     concern.Type `json:"offline_notify"`
}

GroupConcernNotifyConfig 推送配置

func (*GroupConcernNotifyConfig) CheckOfflineNotify added in v0.0.13

func (g *GroupConcernNotifyConfig) CheckOfflineNotify(ctype concern.Type) bool

func (*GroupConcernNotifyConfig) CheckTitleChangeNotify added in v0.0.13

func (g *GroupConcernNotifyConfig) CheckTitleChangeNotify(ctype concern.Type) bool

type Hook added in v0.0.13

type Hook interface {
	NewsFilterHook(notify concern.Notify) *HookResult
	AtBeforeHook(notify concern.Notify) *HookResult
	ShouldSendHook(notify concern.Notify) *HookResult
}

type HookResult added in v0.0.13

type HookResult struct {
	Pass   bool
	Reason string
}

HookResult Pass是false的时候,要把具体失败的地方填入Reason

func (*HookResult) PassOrReason added in v0.0.13

func (h *HookResult) PassOrReason(pass bool, reason string)

type KeySet

type KeySet interface {
	GroupConcernStateKey(keys ...interface{}) string
	GroupConcernConfigKey(keys ...interface{}) string
	FreshKey(keys ...interface{}) string
	GroupAtAllMarkKey(keys ...interface{}) string
	ParseGroupConcernStateKey(key string) (groupCode int64, id interface{}, err error)
}

type NotifyManager added in v0.0.20

type NotifyManager interface {
	Callback
	Hook
}

type StateManager

type StateManager struct {
	*localdb.ShortCut
	KeySet
	// contains filtered or unexported fields
}

func NewStateManager

func NewStateManager(keySet KeySet, useEmit bool) *StateManager

func (*StateManager) AddGroupConcern

func (c *StateManager) AddGroupConcern(groupCode int64, id interface{}, ctype concern.Type) (newCtype concern.Type, err error)

func (*StateManager) CheckAndSetAtAllMark added in v0.0.10

func (c *StateManager) CheckAndSetAtAllMark(groupCode int64, id interface{}) (result bool)

CheckAndSetAtAllMark 检查@全体标记是否过期,已过期返回true,并重置标记,否则返回false。 因为@全体有次数限制,并且较为恼人,故设置标记,两次@全体之间必须有间隔。

func (*StateManager) CheckConcern

func (c *StateManager) CheckConcern(id interface{}, ctype concern.Type) error

func (*StateManager) CheckGroupConcern

func (c *StateManager) CheckGroupConcern(groupCode int64, id interface{}, ctype concern.Type) error

func (*StateManager) EmitFreshCore

func (c *StateManager) EmitFreshCore(name string, fresher func(ctype concern.Type, id interface{}) error)

func (*StateManager) FreshAll

func (c *StateManager) FreshAll()

func (*StateManager) FreshCheck

func (c *StateManager) FreshCheck(id interface{}, setTTL bool) (result bool, err error)

func (*StateManager) FreshIndex

func (c *StateManager) FreshIndex(groups ...int64)

func (*StateManager) GetConcern

func (c *StateManager) GetConcern(id interface{}) (result concern.Type, err error)

GetConcern return the concern.Type combined from all group for an id

func (*StateManager) GetGroupConcern

func (c *StateManager) GetGroupConcern(groupCode int64, id interface{}) (result concern.Type, err error)

GetGroupConcern return the concern.Type in specific group for an id

func (*StateManager) GetGroupConcernConfig added in v0.0.10

func (c *StateManager) GetGroupConcernConfig(groupCode int64, id interface{}) (concernConfig *GroupConcernConfig)

GetGroupConcernConfig always return non-nil

func (*StateManager) GroupTypeById

func (c *StateManager) GroupTypeById(ids []interface{}, types []concern.Type) ([]interface{}, []concern.Type, error)

func (*StateManager) List

func (c *StateManager) List(filter func(groupCode int64, id interface{}, p concern.Type) bool) (idGroups []int64, ids []interface{}, idTypes []concern.Type, err error)

func (*StateManager) ListByGroup

func (c *StateManager) ListByGroup(groupCode int64, filter func(id interface{}, p concern.Type) bool) (ids []interface{}, idTypes []concern.Type, err error)

func (*StateManager) ListIds added in v0.0.8

func (c *StateManager) ListIds() (ids []interface{}, err error)

func (*StateManager) OperateGroupConcernConfig added in v0.0.10

func (c *StateManager) OperateGroupConcernConfig(groupCode int64, id interface{}, f func(concernConfig *GroupConcernConfig) bool) error

OperateGroupConcernConfig 在一个rw事务中获取GroupConcernConfig并交给函数,如果返回true,就保存GroupConcernConfig,否则就回滚。

func (*StateManager) RemoveAllByGroupCode

func (c *StateManager) RemoveAllByGroupCode(groupCode int64) (keys []string, err error)

func (*StateManager) RemoveAllById

func (c *StateManager) RemoveAllById(_id interface{}) (err error)

func (*StateManager) RemoveGroupConcern

func (c *StateManager) RemoveGroupConcern(groupCode int64, id interface{}, ctype concern.Type) (newCtype concern.Type, err error)

func (*StateManager) Start

func (c *StateManager) Start() error

func (*StateManager) Stop added in v0.0.19

func (c *StateManager) Stop()

Jump to

Keyboard shortcuts

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