lsp

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2023 License: AGPL-3.0 Imports: 46 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RollCommand    = "roll"
	CheckinCommand = "签到"
	ScoreCommand   = "查询积分"
	GrantCommand   = "grant"
	LspCommand     = "lsp"
	WatchCommand   = "watch"
	UnwatchCommand = "unwatch"
	ListCommand    = "list"
	SetuCommand    = "色图"
	HuangtuCommand = "黄图"
	EnableCommand  = "enable"
	DisableCommand = "disable"
	ReverseCommand = "倒放"
	HelpCommand    = "help"
	ConfigCommand  = "config"
)
View Source
const (
	PingCommand          = "ping"
	LogCommand           = "log"
	BlockCommand         = "block"
	SysinfoCommand       = "sysinfo"
	WhosyourdaddyCommand = "whosyourdaddy"
	QuitCommand          = "quit"
	ModeCommand          = "mode"
	GroupRequestCommand  = "群邀请"
	FriendRequestCommand = "好友申请"
	AdminCommand         = "admin"
	SilenceCommand       = "silence"
	NoUpdateCommand      = "退订更新"
	AbnormalConcernCheck = "检测异常订阅"
	CleanConcern         = "清除订阅"
)

private command

View Source
const LspSupportVersion int64 = 1
View Source
const LspVersionName = "lsp"
View Source
const ModuleName = "me.sora233.Lsp"

Variables

View Source
var (
	CommitId  = "UNKNOWN"
	BuildTime = "UNKNOWN"
	Tags      = "UNKNOWN"
)
View Source
var CommandMaps = map[string]string{
	"RollCommand":          RollCommand,
	"CheckinCommand":       CheckinCommand,
	"ScoreCommand":         ScoreCommand,
	"GrantCommand":         GrantCommand,
	"LspCommand":           LspCommand,
	"WatchCommand":         WatchCommand,
	"UnwatchCommand":       UnwatchCommand,
	"ListCommand":          ListCommand,
	"SetuCommand":          SetuCommand,
	"HuangtuCommand":       HuangtuCommand,
	"EnableCommand":        EnableCommand,
	"DisableCommand":       DisableCommand,
	"ReverseCommand":       ReverseCommand,
	"HelpCommand":          HelpCommand,
	"ConfigCommand":        ConfigCommand,
	"PingCommand":          PingCommand,
	"LogCommand":           LogCommand,
	"BlockCommand":         BlockCommand,
	"SysinfoCommand":       SysinfoCommand,
	"WhosyourdaddyCommand": WhosyourdaddyCommand,
	"QuitCommand":          QuitCommand,
	"ModeCommand":          ModeCommand,
	"GroupRequestCommand":  GroupRequestCommand,
	"FriendRequestCommand": FriendRequestCommand,
	"AdminCommand":         AdminCommand,
	"SilenceCommand":       SilenceCommand,
	"NoUpdateCommand":      NoUpdateCommand,
	"AbnormalConcernCheck": AbnormalConcernCheck,
	"CleanConcern":         CleanConcern,
}
View Source
var Debug = false
View Source
var Instance = &Lsp{
	concernNotify:          concern.ReadNotifyChan(),
	stop:                   make(chan interface{}),
	status:                 NewStatus(),
	msgLimit:               semaphore.NewWeighted(3),
	PermissionStateManager: permission.NewStateManager(),
	LspStateManager:        NewStateManager(),
	cron:                   cron.New(cron.WithLogger(cron.VerbosePrintfLogger(cronLog))),
}

Functions

func CheckCustomGroupCommand

func CheckCustomGroupCommand(command string) bool

func CheckCustomPrivateCommand

func CheckCustomPrivateCommand(command string) bool

func CheckOperateableCommand

func CheckOperateableCommand(command string) bool

func CheckUpdate

func CheckUpdate() string

func CheckValidCommand

func CheckValidCommand(command string) bool

func CombineCommand

func CombineCommand(command string) string

func IAbnormalConcernCheck

func IAbnormalConcernCheck(c *MessageContext)

func ICleanConcern

func ICleanConcern(c *MessageContext, abnormal bool, groupCodes []int64, rawSite string, rawType string)

func IConfigAtAllCmd

func IConfigAtAllCmd(c *MessageContext, groupCode int64, id string, site string, ctype concern_type.Type, on bool)

func IConfigAtCmd

func IConfigAtCmd(c *MessageContext, groupCode int64, id string, site string, ctype concern_type.Type, action string, QQ []int64)

func IConfigFilterCmdClear

func IConfigFilterCmdClear(c *MessageContext, groupCode int64, id string, site string, ctype concern_type.Type)

func IConfigFilterCmdNotType

func IConfigFilterCmdNotType(c *MessageContext, groupCode int64, id string, site string, ctype concern_type.Type, types []string)

func IConfigFilterCmdShow

func IConfigFilterCmdShow(c *MessageContext, groupCode int64, id string, site string, ctype concern_type.Type)

func IConfigFilterCmdText

func IConfigFilterCmdText(c *MessageContext, groupCode int64, id string, site string, ctype concern_type.Type, keywords []string)

func IConfigFilterCmdType

func IConfigFilterCmdType(c *MessageContext, groupCode int64, id string, site string, ctype concern_type.Type, types []string)

func IConfigOfflineNotifyCmd

func IConfigOfflineNotifyCmd(c *MessageContext, groupCode int64, id string, site string, ctype concern_type.Type, on bool)

func IConfigTitleNotifyCmd

func IConfigTitleNotifyCmd(c *MessageContext, groupCode int64, id string, site string, ctype concern_type.Type, on bool)

func IEnable

func IEnable(c *MessageContext, groupCode int64, command string, disable bool)

func IGrantCmd

func IGrantCmd(c *MessageContext, groupCode int64, command string, grantTo int64, del bool)

func IGrantRole

func IGrantRole(c *MessageContext, groupCode int64, grantRole permission.RoleType, grantTo int64, del bool)

func IList

func IList(c *MessageContext, groupCode int64, site string)

func ISilenceCmd

func ISilenceCmd(c *MessageContext, groupCode int64, delete bool)

func IWatch

func IWatch(c *MessageContext, groupCode int64, id string, site string, watchType concern_type.Type, remove bool)

func ReplyUserInfo

func ReplyUserInfo(c *MessageContext, id string, site string, ctype concern_type.Type)

Types

type KeySet

type KeySet struct{}

func (KeySet) GroupInvitedKey

func (KeySet) GroupInvitedKey(keys ...interface{}) string

func (KeySet) GroupMessageImageKey

func (KeySet) GroupMessageImageKey(keys ...interface{}) string

func (KeySet) GroupMuteKey

func (KeySet) GroupMuteKey(keys ...interface{}) string

func (KeySet) ModeKey

func (KeySet) ModeKey() string

func (KeySet) NewFriendRequestKey

func (KeySet) NewFriendRequestKey(keys ...interface{}) string

type Lsp

type Lsp struct {
	PermissionStateManager *permission.StateManager
	LspStateManager        *StateManager
	// contains filtered or unexported fields
}

func (*Lsp) CommandShowName

func (l *Lsp) CommandShowName(command string) string

func (*Lsp) ConcernNotify

func (l *Lsp) ConcernNotify()

func (*Lsp) CronStart

func (l *Lsp) CronStart()

func (*Lsp) CronStop

func (l *Lsp) CronStop()

func (*Lsp) CronjobReload

func (l *Lsp) CronjobReload()

func (*Lsp) FreshIndex

func (l *Lsp) FreshIndex()

func (*Lsp) GM

func (l *Lsp) GM(res []interface{}) []*message.GroupMessage

func (*Lsp) GetImageFromPool

func (l *Lsp) GetImageFromPool(options ...image_pool.OptionFunc) ([]image_pool.Image, error)

func (*Lsp) Init

func (l *Lsp) Init()

func (*Lsp) MiraiGoModule

func (l *Lsp) MiraiGoModule() bot.ModuleInfo

func (*Lsp) NewVersionNotify

func (l *Lsp) NewVersionNotify(newVersionChan <-chan string)

func (*Lsp) NotifyMessage

func (l *Lsp) NotifyMessage(inotify concern.Notify) *mmsg.MSG

func (*Lsp) PM

func (l *Lsp) PM(res []interface{}) []*message.PrivateMessage

func (*Lsp) PostInit

func (l *Lsp) PostInit()

func (*Lsp) PostStart

func (l *Lsp) PostStart(bot *bot.Bot)

func (*Lsp) RemoveAllByGroup

func (l *Lsp) RemoveAllByGroup(groupCode int64)

func (*Lsp) SendMsg

func (l *Lsp) SendMsg(m *mmsg.MSG, target mmsg.Target) (res []interface{})

SendMsg 总是返回至少一个

func (*Lsp) Serve

func (l *Lsp) Serve(bot *bot.Bot)

func (*Lsp) Start

func (l *Lsp) Start(bot *bot.Bot)

func (*Lsp) Stop

func (l *Lsp) Stop(bot *bot.Bot, wg *sync.WaitGroup)

type LspGroupCommand

type LspGroupCommand struct {
	*Runtime
	// contains filtered or unexported fields
}

func NewLspGroupCommand

func NewLspGroupCommand(l *Lsp, msg *message.GroupMessage) *LspGroupCommand

func (*LspGroupCommand) CheckinCommand

func (lgc *LspGroupCommand) CheckinCommand()

func (*LspGroupCommand) CleanConcernCommand

func (lgc *LspGroupCommand) CleanConcernCommand()

func (*LspGroupCommand) ConfigCommand

func (lgc *LspGroupCommand) ConfigCommand()

func (*LspGroupCommand) DebugCheck

func (lgc *LspGroupCommand) DebugCheck() bool

func (*LspGroupCommand) DefaultLogger

func (lgc *LspGroupCommand) DefaultLogger() *logrus.Entry

func (*LspGroupCommand) DefaultLoggerWithCommand

func (lgc *LspGroupCommand) DefaultLoggerWithCommand(command string) *logrus.Entry

func (*LspGroupCommand) EnableCommand

func (lgc *LspGroupCommand) EnableCommand(disable bool)

func (*LspGroupCommand) Execute

func (lgc *LspGroupCommand) Execute()

func (*LspGroupCommand) GrantCommand

func (lgc *LspGroupCommand) GrantCommand()

func (*LspGroupCommand) HelpCommand

func (lgc *LspGroupCommand) HelpCommand()

func (*LspGroupCommand) ListCommand

func (lgc *LspGroupCommand) ListCommand()

func (*LspGroupCommand) LspCommand

func (lgc *LspGroupCommand) LspCommand()

func (*LspGroupCommand) NewMessageContext

func (lgc *LspGroupCommand) NewMessageContext(log *logrus.Entry) *MessageContext

func (*LspGroupCommand) ReverseCommand

func (lgc *LspGroupCommand) ReverseCommand()

func (*LspGroupCommand) RollCommand

func (lgc *LspGroupCommand) RollCommand()

func (*LspGroupCommand) ScoreCommand

func (lgc *LspGroupCommand) ScoreCommand()

func (*LspGroupCommand) SetuCommand

func (lgc *LspGroupCommand) SetuCommand(r18 bool)

func (*LspGroupCommand) SilenceCommand

func (lgc *LspGroupCommand) SilenceCommand()

func (*LspGroupCommand) WatchCommand

func (lgc *LspGroupCommand) WatchCommand(remove bool)

type LspPrivateCommand

type LspPrivateCommand struct {
	*Runtime
	// contains filtered or unexported fields
}

func NewLspPrivateCommand

func NewLspPrivateCommand(l *Lsp, msg *message.PrivateMessage) *LspPrivateCommand

func (*LspPrivateCommand) AbnormalConcernCheckCommand

func (c *LspPrivateCommand) AbnormalConcernCheckCommand()

func (*LspPrivateCommand) AdminCommand

func (c *LspPrivateCommand) AdminCommand()

func (*LspPrivateCommand) BlockCommand

func (c *LspPrivateCommand) BlockCommand()

func (*LspPrivateCommand) CleanConcernCommand

func (c *LspPrivateCommand) CleanConcernCommand()

func (*LspPrivateCommand) ConfigCommand

func (c *LspPrivateCommand) ConfigCommand()

func (*LspPrivateCommand) DebugCheck

func (c *LspPrivateCommand) DebugCheck() bool

func (*LspPrivateCommand) DefaultLogger

func (c *LspPrivateCommand) DefaultLogger() *logrus.Entry

func (*LspPrivateCommand) DefaultLoggerWithCommand

func (c *LspPrivateCommand) DefaultLoggerWithCommand(command string) *logrus.Entry

func (*LspPrivateCommand) EnableCommand

func (c *LspPrivateCommand) EnableCommand(disable bool)

func (*LspPrivateCommand) Execute

func (c *LspPrivateCommand) Execute()

func (*LspPrivateCommand) FriendRequestCommand

func (c *LspPrivateCommand) FriendRequestCommand()

func (*LspPrivateCommand) GrantCommand

func (c *LspPrivateCommand) GrantCommand()

func (*LspPrivateCommand) GroupRequestCommand

func (c *LspPrivateCommand) GroupRequestCommand()

func (*LspPrivateCommand) HelpCommand

func (c *LspPrivateCommand) HelpCommand()

func (*LspPrivateCommand) ListCommand

func (c *LspPrivateCommand) ListCommand()

func (*LspPrivateCommand) LogCommand

func (c *LspPrivateCommand) LogCommand()

func (*LspPrivateCommand) ModeCommand

func (c *LspPrivateCommand) ModeCommand()

func (*LspPrivateCommand) NewMessageContext

func (c *LspPrivateCommand) NewMessageContext(log *logrus.Entry) *MessageContext

func (*LspPrivateCommand) NoUpdateCommand

func (c *LspPrivateCommand) NoUpdateCommand()

func (*LspPrivateCommand) PingCommand

func (c *LspPrivateCommand) PingCommand()

func (*LspPrivateCommand) QuitCommand

func (c *LspPrivateCommand) QuitCommand()

func (*LspPrivateCommand) SilenceCommand

func (c *LspPrivateCommand) SilenceCommand()

func (*LspPrivateCommand) SysinfoCommand

func (c *LspPrivateCommand) SysinfoCommand()

func (*LspPrivateCommand) WatchCommand

func (c *LspPrivateCommand) WatchCommand(remove bool)

func (*LspPrivateCommand) WhosyourdaddyCommand

func (c *LspPrivateCommand) WhosyourdaddyCommand()

type MessageContext

type MessageContext struct {
	ReplyFunc             func(m *mmsg.MSG) interface{}
	SendFunc              func(m *mmsg.MSG) interface{}
	NoPermissionReplyFunc func() interface{}
	DisabledReply         func() interface{}
	GlobalDisabledReply   func() interface{}
	Lsp                   *Lsp
	Log                   *logrus.Entry
	Target                mmsg.Target
	Sender                *message.Sender
}

func NewMessageContext

func NewMessageContext() *MessageContext

func (*MessageContext) GetLog

func (c *MessageContext) GetLog() *logrus.Entry

func (*MessageContext) GetSender

func (c *MessageContext) GetSender() *message.Sender

func (*MessageContext) GetTarget

func (c *MessageContext) GetTarget() mmsg.Target

func (*MessageContext) IsFromGroup

func (c *MessageContext) IsFromGroup() bool

func (*MessageContext) IsFromPrivate

func (c *MessageContext) IsFromPrivate() bool

func (*MessageContext) NoPermissionReply

func (c *MessageContext) NoPermissionReply() interface{}

func (*MessageContext) Reply

func (c *MessageContext) Reply(m *mmsg.MSG) interface{}

func (*MessageContext) Send

func (c *MessageContext) Send(m *mmsg.MSG) interface{}

func (*MessageContext) TextReply

func (c *MessageContext) TextReply(text string) interface{}

func (*MessageContext) TextSend

func (c *MessageContext) TextSend(text string) interface{}

type Mode

type Mode string
const (
	PublicMode  Mode = "public"
	PrivateMode Mode = "private"
	ProtectMode Mode = "protect"
)

type Runtime

type Runtime struct {
	*parser.Parser
	// contains filtered or unexported fields
}

func NewRuntime

func NewRuntime(l *Lsp, silence ...bool) *Runtime

func (*Runtime) Debug

func (r *Runtime) Debug()

func (*Runtime) Exit

func (r *Runtime) Exit(int)

func (*Runtime) ParseRawSite

func (r *Runtime) ParseRawSite(rawSite string) (string, error)

func (*Runtime) ParseRawSiteAndType

func (r *Runtime) ParseRawSiteAndType(rawSite string, rawType string) (string, concern_type.Type, error)

type StateManager

type StateManager struct {
	*localdb.ShortCut
	KeySet
}

func NewStateManager

func NewStateManager() *StateManager

func (*StateManager) DeleteGroupInvitedRequest

func (s *StateManager) DeleteGroupInvitedRequest(requestId int64) (err error)

func (*StateManager) DeleteNewFriendRequest

func (s *StateManager) DeleteNewFriendRequest(requestId int64) (err error)

func (*StateManager) FreshIndex

func (s *StateManager) FreshIndex()

func (*StateManager) GetCurrentMode

func (s *StateManager) GetCurrentMode() Mode

func (*StateManager) GetGroupInvitedRequest

func (s *StateManager) GetGroupInvitedRequest(requestId int64) (result *client.GroupInvitedRequest, err error)

func (*StateManager) GetMessageImageUrl

func (s *StateManager) GetMessageImageUrl(groupCode int64, messageID int32) []string

func (*StateManager) GetNewFriendRequest

func (s *StateManager) GetNewFriendRequest(requestId int64) (result *client.NewFriendRequest, err error)

func (*StateManager) IsMode

func (s *StateManager) IsMode(mode Mode) bool

func (*StateManager) IsMuted

func (s *StateManager) IsMuted(groupCode int64, uin int64) bool

func (*StateManager) IsPrivateMode

func (s *StateManager) IsPrivateMode() bool

func (*StateManager) IsProtectMode

func (s *StateManager) IsProtectMode() bool

func (*StateManager) IsPublicMode

func (s *StateManager) IsPublicMode() bool

func (*StateManager) ListGroupInvitedRequest

func (s *StateManager) ListGroupInvitedRequest() (results []*client.GroupInvitedRequest, err error)

func (*StateManager) ListNewFriendRequest

func (s *StateManager) ListNewFriendRequest() (results []*client.NewFriendRequest, err error)

func (*StateManager) Muted

func (s *StateManager) Muted(groupCode int64, uin int64, t int32) error

func (*StateManager) PopGroupInvitor

func (s *StateManager) PopGroupInvitor(groupCode int64) (int64, error)

func (*StateManager) SaveGroupInvitedRequest

func (s *StateManager) SaveGroupInvitedRequest(request *client.GroupInvitedRequest) error

func (*StateManager) SaveGroupInvitor

func (s *StateManager) SaveGroupInvitor(groupCode int64, uin int64) error

func (*StateManager) SaveMessageImageUrl

func (s *StateManager) SaveMessageImageUrl(groupCode int64, messageID int32, msgs []message.IMessageElement) error

func (*StateManager) SaveNewFriendRequest

func (s *StateManager) SaveNewFriendRequest(request *client.NewFriendRequest) error

func (*StateManager) SetMode

func (s *StateManager) SetMode(mode Mode) error

type Status

type Status struct {
	ImagePoolEnable bool
	ProxyPoolEnable bool
}

func NewStatus

func NewStatus() *Status

type V1

type V1 struct {
}

func (*V1) Func

func (v *V1) Func() version.MigrationFunc

func (*V1) TargetVersion

func (v *V1) TargetVersion() int64

Jump to

Keyboard shortcuts

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