Documentation
¶
Overview ¶
Package leafBot @Description:
Package leafBot @Description:
Index ¶
- Constants
- Variables
- func BanPluginByID(id string)
- func BanPluginByName(name string) int
- func CallApi(ctx *gin.Context)
- func Cors() gin.HandlerFunc
- func GetConfig(ctx *gin.Context)
- func GetEngine() (*gin.Engine, error)
- func GetFont() []byte
- func GetFriendList(ctx *gin.Context)
- func GetGroupList(ctx *gin.Context)
- func GetHandleList() map[string][]BaseHandle
- func InitBots()
- func InitPluginManager()
- func InitWindow()
- func LoadConfig()
- func LoadDriver(driver2 Driver)
- func MustReply(event Event, api Api, state *State) bool
- func OnlyGroupMessage(event Event, _ Api) bool
- func OnlySuperUser(event Event, _ Api, _ *State) bool
- func OnlyToMe(event Event, _ Api, state *State) bool
- func OpenUi()
- func StartPlugin(name string) int
- func StartPluginByID(id string)
- type Api
- type BaseHandle
- type CommandChain
- type CommandInt
- type Config
- type Conn
- type Connect
- type ConnectChain
- type ConnectInt
- type DisConnectChain
- type DisConnectInt
- type Driver
- type Event
- func (e Event) CloseMessageChan(id int)
- func (e Event) GetImages() []message.MessageSegment
- func (e Event) GetMoreEvent(rules ...Rule) (int, chan Event)
- func (e Event) GetMsg() message.Message
- func (e Event) GetOneEvent(rules ...Rule) (Event, error)
- func (e Event) GetPlainText() string
- func (e Event) Send(message interface{}) int32
- type Files
- type M
- type MessageChain
- type MessageIds
- type MessageInt
- type MetaChain
- type MetaInt
- type NoticeChain
- type NoticeInt
- type Option
- type Options
- type Plugin
- func (p *Plugin) OnCommand(command string, options ...Option) *commandHandle
- func (p *Plugin) OnConnect() *connectHandle
- func (p *Plugin) OnDisConnect() *disConnectHandle
- func (p *Plugin) OnEndWith(str string, options ...Option) *messageHandle
- func (p *Plugin) OnFullMatch(match string, options ...Option) *messageHandle
- func (p *Plugin) OnFullMatchGroup(matchs []string, options ...Option) *messageHandle
- func (p *Plugin) OnKeyWords(keyword string, options ...Option) *messageHandle
- func (p *Plugin) OnMessage(messageType string, options ...Option) *messageHandle
- func (p *Plugin) OnMeta() *metaHandle
- func (p *Plugin) OnNotice(noticeType string, options ...Option) *noticeHandle
- func (p *Plugin) OnPretreatment() *PretreatmentHandle
- func (p *Plugin) OnRegex(regex string, options ...Option) *commandHandle
- func (p *Plugin) OnRequest(requestType string, options ...Option) *requestHandle
- func (p *Plugin) OnStartWith(str string, options ...Option) *messageHandle
- func (p *Plugin) OnTime(crons string, selfId int, handle func(bot Api))
- func (p *Plugin) SetHelp(help map[string]string)
- type PretreatmentChain
- type PretreatmentHandle
- type PretreatmentInt
- type RequestChain
- type RequestInt
- type Rule
- type Senders
- type State
- type Status
Constants ¶
View Source
const ( JSON = "json" HJSON = "hjson" YAML = "yaml" )
Variables ¶
View Source
var ( ConnectHandles ConnectChain DisConnectHandles DisConnectChain MessageHandles MessageChain RequestHandles RequestChain NoticeHandles NoticeChain CommandHandles CommandChain MetaHandles MetaChain PretreatmentHandles PretreatmentChain )
View Source
var (
DefaultConfig = new(Config)
)
View Source
var ENABLE = false // 是否启用gui
View Source
var (
MessageChan = make(chan Event, 10)
)
Functions ¶
func BanPluginByID ¶
func BanPluginByID(id string)
BanPluginByID * * @Description: 根据id禁用插件 * @param id
func BanPluginByName ¶
BanPluginByName * * @Description: 禁用某个插件 * @param name 插件名 * @return int 禁用的插件个数
func Cors ¶ added in v1.1.3
func Cors() gin.HandlerFunc
func GetEngine ¶ added in v1.1.4
GetEngine *
- @Description: 获取web的引擎
- @return *gin.Engine
- @return error
- example
func GetFont ¶ added in v1.1.4
func GetFont() []byte
GetFont *
- @Description: 向外导出思源黑体字体文件
- @return []byte
- example
func GetFriendList ¶
func GetGroupList ¶
func GetHandleList ¶
func GetHandleList() map[string][]BaseHandle
func InitPluginManager ¶
func InitPluginManager()
func LoadConfig ¶
func LoadConfig()
func LoadDriver ¶ added in v1.1.2
func LoadDriver(driver2 Driver)
LoadDriver *
- @Description: 为leafBot注册一个驱动
- @param driver2 实现了Driver接口的驱动
- example
func MustReply ¶ added in v1.1.4
MustReply *
- @Description:
- @param event
- @param api
- @param state
- @return bool
- example
func OnlySuperUser ¶
OnlySuperUser *
- @Description: 加了该rule的插件只会对配置文件中配置的管理员用户进行响应
- @param event leafBot event
- @param bot bot实例对象
- @return bool 是否通过该rule验证
- example
func OnlyToMe ¶
OnlyToMe *
- @Description: 添加了该rule的插件需要在群里艾特或者私聊才会进行响应
- @param event leafBot event
- @param bot bot实例对象
- @return bool 返回是否验证通过该rule
- example
func StartPlugin ¶
StartPlugin * * @Description: 启用某个插件 * @param name 插件名 * @return int 启用插件个数
func StartPluginByID ¶
func StartPluginByID(id string)
Types ¶
type Api ¶
type Api interface {
SendGroupMsg(groupId int, message interface{}) int32
SendPrivateMsg(userId int, message interface{}) int32
DeleteMsg(messageId int32)
GetMsg(messageId int32) gjson.Result
SetGroupBan(groupId int, userId int, duration int)
SetGroupCard(groupId int, userId int, card string)
SendMsg(messageType string, userId int, groupId int, message interface{}) int32
SendLike(userId int, times int)
SetGroupKick(groupId int, userId int, rejectAddRequest bool)
SetGroupAnonymousBan(groupId int, flag string, duration int)
SetGroupWholeBan(groupId int, enable bool)
SetGroupAdmin(groupId int, UserId int, enable bool)
SetGroupAnonymous(groupId int, enable bool)
SetGroupName(groupId int, groupName string)
SetGroupLeave(groupId int, isDisMiss bool)
SetGroupSpecialTitle(groupId int, userId int, specialTitle string, duration int)
SetFriendAddRequest(flag string, approve bool, remark string)
SetGroupAddRequest(flag string, subType string, approve bool, reason string)
GetLoginInfo() gjson.Result
GetStrangerInfo(userId int, noCache bool) gjson.Result
GetFriendList() gjson.Result
GetGroupInfo(groupId int, noCache bool) gjson.Result
GetGroupList() gjson.Result
GetGroupMemberInfo(groupId int, UserId int, noCache bool) gjson.Result
GetGroupMemberList(groupId int) gjson.Result
GetGroupHonorInfo(groupId int, honorType string) gjson.Result
GetCookies(domain string) gjson.Result
GetCsrfToken() gjson.Result
GetCredentials(domain string) gjson.Result
GetRecord(file, outFormat string) gjson.Result
GetImage(file string) gjson.Result
CanSendImage() bool
CanSendRecord() bool
GetStatus() gjson.Result
SetRestart(delay int)
CleanCache()
DownloadFile(url string, threadCount int, headers []string) gjson.Result
GetGroupMsgHistory(messageSeq int64, groupId int) gjson.Result
GetOnlineClients(noCache bool) gjson.Result
GetVipInfoTest(UserId int) gjson.Result
SendGroupNotice(groupId int, content string)
ReloadEventFilter()
SetEssenceMsg(messageId int)
DeleteEssenceMsg(messageId int)
GetEssenceMsgList(groupId int)
CheckUrlSafely(url string) int
UploadGroupFile(groupId int, file string, name string, folder string)
SetGroupNameSpecial(groupId int, groupName string)
SetGroupPortrait(groupId int, file string, cache int)
GetMsgSpecial(messageId int) gjson.Result
GetForwardMsg(messageId int) gjson.Result
SendGroupForwardMsg(groupId int, messages interface{})
GetWordSlices(content string) gjson.Result
OcrImage(image string) gjson.Result
GetGroupSystemMsg() gjson.Result
GetGroupFileSystemInfo(groupId int) gjson.Result
GetGroupRootFiles(groupId int) gjson.Result
GetGroupFilesByFolder(groupId int, folderId string) gjson.Result
GetGroupFileUrl(groupId int, fileId string, busid int) gjson.Result
GetGroupAtAllRemain(groupId int) gjson.Result
CallApi(action string, params interface{}) interface{}
}
Api @Description:
type BaseHandle ¶
type CommandChain ¶
type CommandChain []*commandHandle
func (CommandChain) Len ¶
func (c CommandChain) Len() int
func (CommandChain) Less ¶
func (c CommandChain) Less(i, j int) bool
func (CommandChain) Swap ¶
func (c CommandChain) Swap(i, j int)
type CommandInt ¶
type CommandInt interface {
SetPluginName(name string) *commandHandle
AddAllies(allies string) *commandHandle
AddRule(rule Rule) *commandHandle
SetWeight(weight int) *commandHandle
SetBlock(IsBlock bool) *commandHandle
AddHandle(f func(event Event, bot Api, state *State))
SetCD(types string, long int) *commandHandle
}
type Config ¶
type Config struct {
NickName []string `json:"nick_name" yaml:"nick_name" hjson:"nick_name"`
Admin int `json:"admin" yaml:"admin" hjson:"admin"`
Host string `json:"host" yaml:"host" hjson:"host"`
Port int `json:"port" yaml:"port" hjson:"port"`
LogLevel string `json:"log_level" yaml:"log_level" hjson:"log_level"`
LogTruncate bool `json:"log_truncate" yaml:"log_truncate" hjson:"log_truncate"`
SuperUser []int `json:"super_user" yaml:"super_user" hjson:"super_user"`
CommandStart []string `json:"command_start" yaml:"command_start" hjson:"command_start"`
EnablePlaywright bool `json:"enable_playwright" yaml:"enable_playwright" hjson:"enable_playwright"`
Plugins struct {
FlashGroupID int `json:"flash_group_id" yaml:"flash_group_id" hjson:"flash_group_id"`
AlApiToken string `json:"al_api_token" yaml:"al_api_token" hjson:"al_api_token"`
EnableReplyTome bool `json:"enable_reply_tome" yaml:"enable_reply_tome" hjson:"enable_reply_tome"`
Welcome []struct {
GroupId int `json:"group_id" yaml:"group_id" hjson:"group_id"`
Message string `json:"message" yaml:"message" hjson:"message"`
} `json:"welcome" yaml:"welcome" hjson:"welcome"`
GithubToken string `json:"github_token" yaml:"github_token" hjson:"github_token"`
AutoPassFriendRequest []string `json:"auto_pass_friend_request" yaml:"auto_pass_friend_request" hjson:"auto_pass_friend_request"`
} `json:"plugins" yaml:"plugins" hjson:"plugins"`
Datas map[string]interface{} `json:"datas" yaml:"datas" hjson:"datas"`
}
Config @Description:
type Conn ¶ added in v1.1.2
type Conn interface {
// Do
// @Description: 执行一个api
// @param interface{}
//
Do(interface{})
// GetResponse
// @Description: 获取一次api的执行结果
// @param echo 标识一次执行的唯一参数
// @return []byte 响应结果
// @return error 超时会返回一个error
//
GetResponse(echo string) ([]byte, error)
GetSelfId() int64
}
Conn @Description: 所有bot对象都应该实现该接口
type ConnectChain ¶
type ConnectChain []*connectHandle
type ConnectInt ¶
type DisConnectChain ¶
type DisConnectChain []*disConnectHandle
type DisConnectInt ¶
type Driver ¶ added in v1.1.2
type Driver interface {
// Run
// @Description: 运行该驱动的接口,该接口应该为阻塞式运行
//
Run()
// GetEvent
// @Description: 返回一个chan,该chan为事件传递的chan
// @return chan
//
GetEvent() chan []byte
OnConnect(func(selfId int64, host string, clientRole string))
OnDisConnect(func(selfId int64))
// GetBot
// @Description: 获取一个实现了APi接口的bot
// @param int64 bot的id
// @return interface{}
//
GetBot(int64) interface{}
// GetBots
// @Description: 获取所有bot
// @return map[int64]interface{}
//
GetBots() map[int64]interface{}
// SetAddress
// @Description: 设置driver的运行地址
// @param string2
//
SetAddress(string2 string)
SetPort(port int)
}
Driver @Description:
type Event ¶
type Event struct {
Anonymous anonymous `json:"anonymous"`
Font int `json:"font"`
GroupId int `json:"group_id"`
Message message.Message `json:"message"`
MessageType string `json:"message_type"`
PostType string `json:"post_type"`
RawMessage string `json:"raw_message"`
SelfId int `json:"self_id"`
Sender Senders `json:"sender"`
SubType string `json:"sub_type"`
UserId int `json:"user_id"`
Time int `json:"time"`
NoticeType string `json:"notice_type"`
RequestType string `json:"request_type"`
Comment string `json:"comment"`
Flag string `json:"flag"`
OperatorId int `json:"operator_id"`
File Files `json:"file"`
Duration int64 `json:"duration"`
TargetId int64 `json:"target_id"` //运气王id
HonorType string `json:"honor_type"`
MetaEventType string `json:"meta_event_type"`
Status Status `json:"status"`
Interval int `json:"interval"`
CardNew string `json:"card_new"` //新名片
CardOld string `json:"card_old"` //旧名片
MessageIds
}
func (Event) CloseMessageChan ¶ added in v1.1.2
CloseMessageChan
@Description: 关闭session,即从等待队列中删除 @receiver b @param id int
func (Event) GetImages ¶
func (e Event) GetImages() []message.MessageSegment
func (Event) GetMoreEvent ¶ added in v1.1.2
GetMoreEvent
@Description: 获取一个通道不断从用户获取消息 @receiver b @param rules ...Rule @return int int 对应session在队列中的编号,后面关闭需要该编号 @return chan Event 事件通道
func (Event) GetOneEvent ¶ added in v1.1.2
GetOneEvent
@Description: 向session队列里面添加一个对象,等待用户的响应,设置超时时间 @receiver b @param rules ...Rule @return Event Event @return error error
func (Event) GetPlainText ¶
type M ¶
type M interface {
// contains filtered or unexported methods
}
M
通过id从插件列表获取插件 所有的插件队列都实现了该接口
type MessageChain ¶
type MessageChain []*messageHandle
func (MessageChain) Len ¶
func (m MessageChain) Len() int
func (MessageChain) Less ¶
func (m MessageChain) Less(i, j int) bool
func (MessageChain) Swap ¶
func (m MessageChain) Swap(i, j int)
type MessageIds ¶
type MessageIds struct {
MessageID int32 `json:"message_id"`
}
type MessageInt ¶
type NoticeChain ¶
type NoticeChain []*noticeHandle
func (NoticeChain) Len ¶
func (n NoticeChain) Len() int
func (NoticeChain) Less ¶
func (n NoticeChain) Less(i, j int) bool
func (NoticeChain) Swap ¶
func (n NoticeChain) Swap(i, j int)
type Plugin ¶ added in v1.1.1
type Plugin struct {
Name string
Helps []map[string]string
// contains filtered or unexported fields
}
func (*Plugin) OnDisConnect ¶ added in v1.1.1
func (p *Plugin) OnDisConnect() *disConnectHandle
func (*Plugin) OnFullMatch ¶ added in v1.1.4
func (*Plugin) OnFullMatchGroup ¶ added in v1.1.4
func (*Plugin) OnKeyWords ¶ added in v1.1.1
func (*Plugin) OnPretreatment ¶ added in v1.1.1
func (p *Plugin) OnPretreatment() *PretreatmentHandle
func (*Plugin) OnStartWith ¶ added in v1.1.1
type PretreatmentChain ¶
type PretreatmentChain []*PretreatmentHandle
func (PretreatmentChain) Len ¶
func (p PretreatmentChain) Len() int
func (PretreatmentChain) Less ¶
func (p PretreatmentChain) Less(i, j int) bool
func (PretreatmentChain) Swap ¶
func (p PretreatmentChain) Swap(i, j int)
type PretreatmentHandle ¶
type PretreatmentHandle struct {
BaseHandle
// contains filtered or unexported fields
}
func (*PretreatmentHandle) AddHandle ¶
func (p *PretreatmentHandle) AddHandle(f func(event Event, bot Api) bool)
AddHandle *
- @Description:
- @receiver p
- @param f
func (*PretreatmentHandle) AddRule ¶
func (p *PretreatmentHandle) AddRule(rule Rule) *PretreatmentHandle
AddRule *
- @Description:
- @receiver p
- @param rule
- @return PretreatmentHandle
func (*PretreatmentHandle) SetPluginName ¶
func (p *PretreatmentHandle) SetPluginName(name string) *PretreatmentHandle
func (*PretreatmentHandle) SetWeight ¶
func (p *PretreatmentHandle) SetWeight(weight int) *PretreatmentHandle
SetWeight *
- @Description:
- @receiver p
- @param weight
- @return PretreatmentHandle
type PretreatmentInt ¶
type PretreatmentInt interface {
SetPluginName(name string) *PretreatmentHandle
AddRule(rule Rule) *PretreatmentHandle
SetWeight(weight int) *PretreatmentHandle
AddHandle(func(event Event, bot Api) bool)
}
type RequestChain ¶
type RequestChain []*requestHandle
func (RequestChain) Len ¶
func (r RequestChain) Len() int
func (RequestChain) Less ¶
func (r RequestChain) Less(i, j int) bool
func (RequestChain) Swap ¶
func (r RequestChain) Swap(i, j int)
type RequestInt ¶
type State ¶
type State struct {
Args []string
Cmd string
Allies []string
RegexResult []string
Data map[string]interface{}
}
State @Description: sdk处理消息后将内容传递给plugin
type Status ¶
type Status struct {
AppEnabled bool `json:"app_enabled"`
AppGood bool `json:"app_good"`
AppInitialized bool `json:"app_initialized"`
Good bool `json:"good"`
Online bool `json:"online"`
PluginsGood interface{} `json:"plugins_good"`
Stat struct {
PacketReceived int `json:"packet_received"`
PacketSent int `json:"packet_sent"`
PacketLost int `json:"packet_lost"`
MessageReceived int `json:"message_received"`
MessageSent int `json:"message_sent"`
DisconnectTimes int `json:"disconnect_times"`
LostTimes int `json:"lost_times"`
LastMessageTime int `json:"last_message_time"`
} `json:"stat"`
}
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
gui
|
|
|
Package utils @Description: Package utils @Description:
|
Package utils @Description: Package utils @Description: |
Click to show internal directories.
Click to hide internal directories.