lsp

package
v1.0.7 Latest Latest
Warning

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

Go to latest
Published: May 16, 2022 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      = "退订更新"
)

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,
}
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 added in v1.0.5

func CheckCustomGroupCommand(command string) bool

func CheckCustomPrivateCommand added in v1.0.5

func CheckCustomPrivateCommand(command string) bool

func CheckOperateableCommand

func CheckOperateableCommand(command string) bool

func CheckUpdate added in v1.0.6

func CheckUpdate() string

func CheckValidCommand

func CheckValidCommand(command string) bool

func CombineCommand added in v0.0.16

func CombineCommand(command string) string

func IConfigAtAllCmd added in v0.0.10

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

func IConfigAtCmd added in v0.0.13

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

func IConfigFilterCmdClear added in v0.0.14

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

func IConfigFilterCmdNotType added in v0.0.14

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

func IConfigFilterCmdShow added in v0.0.14

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

func IConfigFilterCmdText added in v0.0.14

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

func IConfigFilterCmdType added in v0.0.14

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

func IConfigOfflineNotifyCmd added in v0.0.13

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

func IConfigTitleNotifyCmd added in v0.0.13

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

func IEnable added in v0.0.7

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

func IGrantCmd added in v0.0.9

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

func IGrantRole added in v0.0.9

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

func IList added in v0.0.8

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

func ISilenceCmd added in v0.1.3

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

func IWatch added in v0.0.7

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

func ReplyUserInfo added in v0.0.13

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

Types

type KeySet

type KeySet struct{}

func (KeySet) GroupInvitedKey added in v0.1.0

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 added in v0.1.0

func (KeySet) ModeKey() string

func (KeySet) NewFriendRequestKey added in v0.1.0

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

type Lsp

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

func (*Lsp) CommandShowName added in v1.0.3

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

func (*Lsp) ConcernNotify

func (l *Lsp) ConcernNotify()

func (*Lsp) CronStart added in v1.0.7

func (l *Lsp) CronStart()

func (*Lsp) CronStop added in v1.0.7

func (l *Lsp) CronStop()

func (*Lsp) CronjobReload added in v1.0.7

func (l *Lsp) CronjobReload()

func (*Lsp) FreshIndex

func (l *Lsp) FreshIndex()

func (*Lsp) GM added in v1.0.5

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 added in v1.0.6

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

func (*Lsp) NotifyMessage

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

func (*Lsp) PM added in v1.0.5

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

func (*Lsp) PostInit

func (l *Lsp) PostInit()

func (*Lsp) PostStart added in v0.0.6

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

func (*Lsp) RemoveAllByGroup

func (l *Lsp) RemoveAllByGroup(groupCode int64)

func (*Lsp) SendMsg added in v1.0.1

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) ConfigCommand added in v0.0.10

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 added in v0.0.10

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 added in v0.1.3

func (lgc *LspGroupCommand) ScoreCommand()

func (*LspGroupCommand) SetuCommand

func (lgc *LspGroupCommand) SetuCommand(r18 bool)

func (*LspGroupCommand) SilenceCommand added in v0.1.3

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) AdminCommand added in v0.1.3

func (c *LspPrivateCommand) AdminCommand()

func (*LspPrivateCommand) BlockCommand

func (c *LspPrivateCommand) BlockCommand()

func (*LspPrivateCommand) ConfigCommand added in v0.0.10

func (c *LspPrivateCommand) ConfigCommand()

func (*LspPrivateCommand) DebugCheck

func (c *LspPrivateCommand) DebugCheck() bool

func (*LspPrivateCommand) DefaultLogger

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

func (*LspPrivateCommand) DefaultLoggerWithCommand added in v0.0.7

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

func (*LspPrivateCommand) EnableCommand added in v0.0.7

func (c *LspPrivateCommand) EnableCommand(disable bool)

func (*LspPrivateCommand) Execute

func (c *LspPrivateCommand) Execute()

func (*LspPrivateCommand) FriendRequestCommand added in v0.1.0

func (c *LspPrivateCommand) FriendRequestCommand()

func (*LspPrivateCommand) GrantCommand added in v0.0.9

func (c *LspPrivateCommand) GrantCommand()

func (*LspPrivateCommand) GroupRequestCommand added in v0.1.0

func (c *LspPrivateCommand) GroupRequestCommand()

func (*LspPrivateCommand) HelpCommand

func (c *LspPrivateCommand) HelpCommand()

func (*LspPrivateCommand) ListCommand added in v0.0.8

func (c *LspPrivateCommand) ListCommand()

func (*LspPrivateCommand) LogCommand

func (c *LspPrivateCommand) LogCommand()

func (*LspPrivateCommand) ModeCommand added in v0.1.0

func (c *LspPrivateCommand) ModeCommand()

func (*LspPrivateCommand) NewMessageContext added in v0.0.9

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

func (*LspPrivateCommand) NoUpdateCommand added in v1.0.6

func (c *LspPrivateCommand) NoUpdateCommand()

func (*LspPrivateCommand) PingCommand

func (c *LspPrivateCommand) PingCommand()

func (*LspPrivateCommand) QuitCommand added in v0.0.18

func (c *LspPrivateCommand) QuitCommand()

func (*LspPrivateCommand) SilenceCommand added in v0.1.3

func (c *LspPrivateCommand) SilenceCommand()

func (*LspPrivateCommand) SysinfoCommand added in v0.0.8

func (c *LspPrivateCommand) SysinfoCommand()

func (*LspPrivateCommand) WatchCommand added in v0.0.7

func (c *LspPrivateCommand) WatchCommand(remove bool)

func (*LspPrivateCommand) WhosyourdaddyCommand added in v0.0.16

func (c *LspPrivateCommand) WhosyourdaddyCommand()

type MessageContext added in v0.0.9

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 added in v0.0.9

func NewMessageContext() *MessageContext

func (*MessageContext) GetLog added in v1.0.0

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

func (*MessageContext) GetSender added in v1.0.0

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

func (*MessageContext) GetTarget added in v1.0.0

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

func (*MessageContext) IsFromGroup added in v0.0.13

func (c *MessageContext) IsFromGroup() bool

func (*MessageContext) IsFromPrivate added in v0.0.13

func (c *MessageContext) IsFromPrivate() bool

func (*MessageContext) NoPermissionReply added in v0.0.9

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

func (*MessageContext) Reply added in v0.0.9

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

func (*MessageContext) Send added in v0.0.9

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

func (*MessageContext) TextReply added in v0.0.9

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

func (*MessageContext) TextSend added in v1.0.0

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

type Mode added in v0.1.0

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 added in v0.0.7

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

func (*Runtime) ParseRawSiteAndType added in v0.0.7

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 added in v0.1.0

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

func (*StateManager) DeleteNewFriendRequest added in v0.1.0

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

func (*StateManager) FreshIndex

func (s *StateManager) FreshIndex()

func (*StateManager) GetCurrentMode added in v0.1.0

func (s *StateManager) GetCurrentMode() Mode

func (*StateManager) GetGroupInvitedRequest added in v0.1.0

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 added in v0.1.0

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

func (*StateManager) IsMode added in v0.1.0

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

func (*StateManager) IsMuted

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

func (*StateManager) IsPrivateMode added in v0.1.0

func (s *StateManager) IsPrivateMode() bool

func (*StateManager) IsProtectMode added in v0.1.0

func (s *StateManager) IsProtectMode() bool

func (*StateManager) IsPublicMode added in v0.1.0

func (s *StateManager) IsPublicMode() bool

func (*StateManager) ListGroupInvitedRequest added in v0.1.0

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

func (*StateManager) ListNewFriendRequest added in v0.1.0

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 added in v0.0.18

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

func (*StateManager) SaveGroupInvitedRequest added in v0.1.0

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 added in v0.1.0

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

func (*StateManager) SetMode added in v0.1.0

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

type Status

type Status struct {
	ImagePoolEnable bool
	ProxyPoolEnable bool
}

func NewStatus

func NewStatus() *Status

type V1 added in v1.0.0

type V1 struct {
}

func (*V1) Func added in v1.0.0

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

func (*V1) TargetVersion added in v1.0.0

func (v *V1) TargetVersion() int64

Jump to

Keyboard shortcuts

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