leafBot

package module
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Dec 25, 2021 License: AGPL-3.0 Imports: 34 Imported by: 0

README

LeafBot

LeafBot

✨ 基于 go-cqhttp,使用OneBot标准的插件 ✨

cqhttp


安装
    go get github.com/huoxue1/leafBot
插件仓库已移动到leafBotPlugin,若需使用内置插件,请查看该仓库
特别感谢

wdvxdr1123/ZeroBot <借鉴思路>

Mrs4s/go-cqhttp <onebot实现>

nonebot/nonebot2 <流程借鉴>

Documentation

Overview

Package leafBot @Description:

Package leafBot @Description:

Package leafBot @Description:

Index

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

func BanPluginByName(name string) int

BanPluginByName * * @Description: 禁用某个插件 * @param name 插件名 * @return int 禁用的插件个数

func CallApi

func CallApi(ctx *gin.Context)

func Cors added in v1.1.3

func Cors() gin.HandlerFunc

func GetConfig

func GetConfig(ctx *gin.Context)

func GetEngine added in v1.1.4

func GetEngine() (*gin.Engine, error)

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 GetFriendList(ctx *gin.Context)

func GetGroupList

func GetGroupList(ctx *gin.Context)

func GetHandleList

func GetHandleList() map[string][]BaseHandle

func InitBots

func InitBots()

InitBots

@Description:

func InitDefaultPlugin added in v1.1.6

func InitDefaultPlugin()

func InitPluginManager

func InitPluginManager()

func InitWindow

func InitWindow()

InitWindow *

  • @Description:
  • example

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

func MustReply(ctx *Context) bool

MustReply *

  • @Description:
  • @param event
  • @param api
  • @param state
  • @return bool
  • example

func OnlyGroupMessage

func OnlyGroupMessage(ctx *Context) bool

OnlyGroupMessage *

  • @Description:
  • @param event
  • @param _
  • @return bool
  • example

func OnlySuperUser

func OnlySuperUser(ctx *Context) bool

OnlySuperUser *

  • @Description: 加了该rule的插件只会对配置文件中配置的管理员用户进行响应
  • @param event leafBot event
  • @param bot bot实例对象
  • @return bool 是否通过该rule验证
  • example

func OnlyToMe

func OnlyToMe(ctx *Context) bool

OnlyToMe *

  • @Description: 添加了该rule的插件需要在群里艾特或者私聊才会进行响应
  • @param event leafBot event
  • @param bot bot实例对象
  • @return bool 返回是否验证通过该rule
  • example

func OpenUi added in v1.1.0

func OpenUi()

func StartPlugin

func StartPlugin(name string) int

StartPlugin * * @Description: 启用某个插件 * @param name 插件名 * @return int 启用插件个数

func StartPluginByID

func StartPluginByID(id string)

Types

type Api

type Api interface {
	CallApi(action string, params interface{}) gjson.Result
	SendGroupMsg(groupId int, message interface{}) int32
	SendPrivateMsg(userId int, message interface{}) int32
	DeleteMsg(messageId int32)
}

Api @Description:

func GetBotById

func GetBotById(id int) Api

GetBotById

@Description:
@param id int
@return Api

type BaseHandle

type BaseHandle struct {
	ID         string
	Name       string
	Enable     bool
	IsAdmin    bool
	HandleType string
}

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(ctx *Context))
	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"`
	Token            string   `json:"token"`
	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"`
	ListenHost       string   `json:"listen_host" yaml:"listen_host"`
	ListenPort       int      `json:"listen_port" yaml:"listen_port"`
	WebHook          []struct {
		PostHost string `json:"post_host" yaml:"post_host"`
		PostPort int    `json:"post_port" yaml:"post_port"`
		SelfID   int64  `json:"self_id" yaml:"self_id"`
	} `json:"web_hook" yaml:"web_hook" hjson:"web_hook"`
	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 Connect

type Connect struct {
	SelfID     int64
	Host       string
	ClientRole string
}

type ConnectChain

type ConnectChain []*connectHandle

type ConnectInt

type ConnectInt interface {
	SetPluginName(name string) *connectHandle
	AddHandle(func(connect Connect, bot Api))
}

type Context added in v1.1.6

type Context struct {
	Event    *Event
	Bot      Api
	State    *State
	RawEvent gjson.Result
}

Context @Description:

func (*Context) CallApi added in v1.1.6

func (ctx *Context) CallApi(Action string, param interface{}) gjson.Result

func (*Context) CanSendImage added in v1.1.6

func (ctx *Context) CanSendImage() bool

CanSendImage

@Description:
@receiver b
@return Bool

func (*Context) CanSendRecord added in v1.1.6

func (ctx *Context) CanSendRecord() bool

CanSendRecord

@Description:
@receiver b
@return Bool

func (*Context) CheckUrlSafely added in v1.1.6

func (ctx *Context) CheckUrlSafely(url string) int

func (*Context) CleanCache added in v1.1.6

func (ctx *Context) CleanCache()

CleanCache *

  • @Description:
  • @receiver b
  • example

func (*Context) DeleteEssenceMsg added in v1.1.6

func (ctx *Context) DeleteEssenceMsg(messageId int)

func (*Context) DeleteMsg added in v1.1.6

func (ctx *Context) DeleteMsg(messageId int32)

DeleteMsg

@Description:
@receiver b
@param messageId int32

func (*Context) DownloadFile added in v1.1.6

func (ctx *Context) DownloadFile(url string, threadCount int, headers []string) gjson.Result

DownloadFile

@Description:
@receiver b
@param url string
@param threadCount int
@param headers []string
@return DownloadFilePath

func (*Context) GetCookies added in v1.1.6

func (ctx *Context) GetCookies(domain string) gjson.Result

GetCookies

@Description:
@receiver b
@param domain string
@return Cookie

func (*Context) GetCredentials added in v1.1.6

func (ctx *Context) GetCredentials(domain string) gjson.Result

GetCredentials

@Description:
@receiver b
@param domain string
@return Credentials

func (*Context) GetCsrfToken added in v1.1.6

func (ctx *Context) GetCsrfToken() gjson.Result

GetCsrfToken

@Description:
@receiver b
@return CsrfToken

func (*Context) GetEssenceMsgList added in v1.1.6

func (ctx *Context) GetEssenceMsgList(groupId int) gjson.Result

func (*Context) GetForwardMsg added in v1.1.6

func (ctx *Context) GetForwardMsg(messageId int) gjson.Result

GetForwardMsg

@Description:
@receiver b
@param messageId int
@return []ForwardMsg

func (*Context) GetFriendList added in v1.1.6

func (ctx *Context) GetFriendList() gjson.Result

GetFriendList *

  • @Description:
  • @receiver b
  • @return gjson.Result
  • example

func (*Context) GetGroupAtAllRemain added in v1.1.6

func (ctx *Context) GetGroupAtAllRemain(groupId int) gjson.Result

GetGroupAtAllRemain

@Description:
@receiver b
@param groupId int
@return GroupAtAllRemain

func (*Context) GetGroupFileSystemInfo added in v1.1.6

func (ctx *Context) GetGroupFileSystemInfo(groupId int) gjson.Result

GetGroupFileSystemInfo

@Description:
@receiver b
@param groupId int
@return GroupFileSystemInfo

func (*Context) GetGroupFileUrl added in v1.1.6

func (ctx *Context) GetGroupFileUrl(groupId int, fileId string, busid int) gjson.Result

GetGroupFileUrl

@Description:
@receiver b
@param groupId int
@param fileId string
@param busid int
@return FileUrl

func (*Context) GetGroupFilesByFolder added in v1.1.6

func (ctx *Context) GetGroupFilesByFolder(groupId int, folderId string) gjson.Result

GetGroupFilesByFolder

@Description:
@receiver b
@param groupId int
@param folderId string
@return GroupFilesByFolder

func (*Context) GetGroupHonorInfo added in v1.1.6

func (ctx *Context) GetGroupHonorInfo(groupId int, honorType string) gjson.Result

GetGroupHonorInfo

@Description:
@receiver b
@param groupId int
@param honorType string
@return GroupHonorInfo

func (*Context) GetGroupInfo added in v1.1.6

func (ctx *Context) GetGroupInfo(groupId int, noCache bool) gjson.Result

GetGroupInfo *

  • @Description:
  • @receiver b
  • @param groupId
  • @param noCache
  • @return gjson.Result
  • example

func (*Context) GetGroupList added in v1.1.6

func (ctx *Context) GetGroupList() gjson.Result

GetGroupList

@Description:
@receiver b
@return []GroupInfo

func (*Context) GetGroupMemberInfo added in v1.1.6

func (ctx *Context) GetGroupMemberInfo(groupId int, userId int, noCache bool) gjson.Result

GetGroupMemberInfo

@Description:
@receiver b
@param groupId int
@param userId int
@param noCache bool
@return GroupMemberInfo

func (*Context) GetGroupMemberList added in v1.1.6

func (ctx *Context) GetGroupMemberList(groupId int) gjson.Result

GetGroupMemberList

@Description:
@receiver b
@param groupId int
@return []GroupMemberInfo

func (*Context) GetGroupMsgHistory added in v1.1.6

func (ctx *Context) GetGroupMsgHistory(messageSeq int64, groupId int) gjson.Result

GetGroupMsgHistory

@Description:
@receiver b
@param messageSeq int64
@param groupId int
@return MessageHistory

func (*Context) GetGroupRootFiles added in v1.1.6

func (ctx *Context) GetGroupRootFiles(groupId int) gjson.Result

GetGroupRootFiles

@Description:
@receiver b
@param groupId int
@return GroupRootFiles

func (*Context) GetGroupSystemMsg added in v1.1.6

func (ctx *Context) GetGroupSystemMsg() gjson.Result

GetGroupSystemMsg

@Description:
@receiver b
@return GroupSystemMsg

func (*Context) GetImage added in v1.1.6

func (ctx *Context) GetImage(file string) gjson.Result

GetImage

@Description:
@receiver b
@param file string
@return Image

func (*Context) GetLoginInfo added in v1.1.6

func (ctx *Context) GetLoginInfo() gjson.Result

GetLoginInfo

@Description:
@receiver b
@return LoginInfo

func (*Context) GetMsg added in v1.1.6

func (ctx *Context) GetMsg(messageId int32) gjson.Result

GetMsg

@Description:
@receiver b
@param messageId int32
@return GetMessage

func (*Context) GetMsgSpecial added in v1.1.6

func (ctx *Context) GetMsgSpecial(messageId int) gjson.Result

GetMsgSpecial

@Description:
@receiver b
@param messageId int
@return MsgData

func (*Context) GetOnlineClients added in v1.1.6

func (ctx *Context) GetOnlineClients(noCache bool) gjson.Result

GetOnlineClients *

  • @Description:
  • @receiver b
  • @param noCache
  • @return gjson.Result
  • example

func (*Context) GetRecord added in v1.1.6

func (ctx *Context) GetRecord(file, outFormat string) gjson.Result

GetRecord

@Description:
@receiver b
@param file file
@param outFormat string
@return Record

func (*Context) GetStatus added in v1.1.6

func (ctx *Context) GetStatus() gjson.Result

GetStatus

@Description:
@receiver b
@return OnlineStatus

func (*Context) GetStrangerInfo added in v1.1.6

func (ctx *Context) GetStrangerInfo(userId int, noCache bool) gjson.Result

GetStrangerInfo

@Description:
@receiver b
@param userId int
@param noCache bool
@return Senders

func (*Context) GetVipInfoTest added in v1.1.6

func (ctx *Context) GetVipInfoTest(UserId int) gjson.Result

GetVipInfoTest

@Description:
@receiver b
@param UserId int
@return VipInfo

func (*Context) GetWordSlices added in v1.1.6

func (ctx *Context) GetWordSlices(content string) gjson.Result

GetWordSlices

@Description:
@receiver b
@param content string
@return []string

func (*Context) OcrImage added in v1.1.6

func (ctx *Context) OcrImage(image string) gjson.Result

OcrImage

@Description:
@receiver b
@param image string
@return OcrImage

func (*Context) ReloadEventFilter added in v1.1.6

func (ctx *Context) ReloadEventFilter()

ReloadEventFilter

@Description:
@receiver b

func (*Context) Send added in v1.1.6

func (ctx *Context) Send(message interface{}) int32

func (*Context) SendGroupForwardMsg added in v1.1.6

func (ctx *Context) SendGroupForwardMsg(groupId int, messages interface{})

SendGroupForwardMsg

@Description:
@receiver b
@param groupId int
@param messages []Node

func (*Context) SendGroupMsg added in v1.1.6

func (ctx *Context) SendGroupMsg(groupId int, message interface{}) int32

SendGroupMsg *

  • @Description:
  • @receiver b
  • @param groupId
  • @param message
  • @return int32

func (*Context) SendGroupNotice added in v1.1.6

func (ctx *Context) SendGroupNotice(groupId int, content string)

SendGroupNotice

@Description:
@receiver b
@param groupId int
@param content string

func (*Context) SendLike added in v1.1.6

func (ctx *Context) SendLike(userId int, times int)

SendLike

@Description:
@receiver b
@param userId int
@param times int

func (*Context) SendMsg added in v1.1.6

func (ctx *Context) SendMsg(messageType string, userId int, groupId int, message interface{}) int32

SendMsg

@Description:
@receiver b
@param messageType string
@param userId int
@param groupId int
@param message string
@param autoEscape bool
@return int32

func (*Context) SendPrivateMsg added in v1.1.6

func (ctx *Context) SendPrivateMsg(userId int, message interface{}) int32

SendPrivateMsg

@Description:
@receiver b
@param userId int
@param message string
@param autoEscape bool
@return int32

func (*Context) SetEssenceMsg added in v1.1.6

func (ctx *Context) SetEssenceMsg(messageId int)

func (*Context) SetFriendAddRequest added in v1.1.6

func (ctx *Context) SetFriendAddRequest(flag string, approve bool, remark string)

SetFriendAddRequest

@Description:
@receiver b
@param flag string
@param approve bool
@param remark string

func (*Context) SetGroupAddRequest added in v1.1.6

func (ctx *Context) SetGroupAddRequest(flag string, subType string, approve bool, reason string)

SetGroupAddRequest

@Description:
@receiver b
@param flag string
@param subType string
@param approve bool
@param reason string

func (*Context) SetGroupAdmin added in v1.1.6

func (ctx *Context) SetGroupAdmin(groupId int, userId int, enable bool)

SetGroupAdmin

@Description:
@receiver b
@param groupId int
@param userId int
@param enable bool

func (*Context) SetGroupAnonymous added in v1.1.6

func (ctx *Context) SetGroupAnonymous(groupId int, enable bool)

SetGroupAnonymous

@Description:
@receiver b
@param groupId int
@param enable bool

func (*Context) SetGroupAnonymousBan added in v1.1.6

func (ctx *Context) SetGroupAnonymousBan(groupId int, flag string, duration int)

SetGroupAnonymousBan

@Description:
@receiver b
@param groupId int
@param flag string
@param duration int

func (*Context) SetGroupBan added in v1.1.6

func (ctx *Context) SetGroupBan(groupId int, userId int, duration int)

SetGroupBan

@Description:
@receiver b
@param groupId int
@param userId int
@param duration int

func (*Context) SetGroupCard added in v1.1.6

func (ctx *Context) SetGroupCard(groupId int, userId int, card string)

SetGroupCard

@Description:
@receiver b
@param groupId int
@param userId int
@param card string

func (*Context) SetGroupKick added in v1.1.6

func (ctx *Context) SetGroupKick(groupId int, userId int, rejectAddRequest bool)

SetGroupKick

@Description:
@receiver b
@param groupId int
@param userId int
@param rejectAddRequest bool

func (*Context) SetGroupLeave added in v1.1.6

func (ctx *Context) SetGroupLeave(groupId int, isDisMiss bool)

SetGroupLeave

@Description:
@receiver b
@param groupId int
@param isDisMiss bool

func (*Context) SetGroupName added in v1.1.6

func (ctx *Context) SetGroupName(groupId int, groupName string)

SetGroupName

@Description:
@receiver b
@param groupId int
@param groupName string

func (*Context) SetGroupNameSpecial added in v1.1.6

func (ctx *Context) SetGroupNameSpecial(groupId int, groupName string)

SetGroupNameSpecial

@Description:
@receiver b
@param groupId int
@param groupName string

func (*Context) SetGroupPortrait added in v1.1.6

func (ctx *Context) SetGroupPortrait(groupId int, file string, cache int)

SetGroupPortrait

@Description:
@receiver b
@param groupId int
@param file string
@param cache int

func (*Context) SetGroupSpecialTitle added in v1.1.6

func (ctx *Context) SetGroupSpecialTitle(groupId int, userId int, specialTitle string, duration int)

SetGroupSpecialTitle

@Description:
@receiver b
@param groupId int
@param userId int
@param specialTitle string
@param duration int

func (*Context) SetGroupWholeBan added in v1.1.6

func (ctx *Context) SetGroupWholeBan(groupId int, enable bool)

SetGroupWholeBan

@Description:
@receiver b
@param groupId int
@param enable bool

func (*Context) SetRestart added in v1.1.6

func (ctx *Context) SetRestart(delay int)

SetRestart

@Description:
@receiver b
@param delay int

func (*Context) UploadGroupFile added in v1.1.6

func (ctx *Context) UploadGroupFile(groupId int, file string, name string, folder string)

UploadGroupFile

@Description:
@receiver b
@param groupId int
@param file string
@param name string
@param folder string

type CoolDown added in v1.1.6

type CoolDown struct {
	Types string `json:"types"`
	Long  int    `json:"long"`
}

type DisConnectChain

type DisConnectChain []*disConnectHandle

type DisConnectInt

type DisConnectInt interface {
	SetPluginName(name string) *disConnectHandle
	AddHandle(func(selfId int64))
}

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{}

	SetConfig(config map[string]interface{})

	AddWebHook(selfID int64, postHost string, postPort int)

	SetToken(token string)
}

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

func (e Event) CloseMessageChan(id int)

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

func (e Event) GetMoreEvent(rules ...Rule) (int, chan Event)

GetMoreEvent

@Description: 获取一个通道不断从用户获取消息
@receiver b
@param rules ...Rule
@return int  int 对应session在队列中的编号,后面关闭需要该编号
@return chan  Event  事件通道

func (Event) GetMsg

func (e Event) GetMsg() message.Message

GetMsg *

  • @Description:
  • @receiver e
  • @return message.Message

func (Event) GetOneEvent added in v1.1.2

func (e Event) GetOneEvent(rules ...Rule) (Event, error)

GetOneEvent

@Description: 向session队列里面添加一个对象,等待用户的响应,设置超时时间
@receiver b
@param rules ...Rule
@return Event  Event
@return error  error

func (Event) GetPlainText

func (e Event) GetPlainText() string

func (Event) Send added in v1.1.2

func (e Event) Send(message interface{}) int32

type Files

type Files struct {
	Id      string `json:"id"`
	Name    string `json:"name"`
	Size    int64  `json:"size"`
	Busid   int64  `json:"busid"`
	FileUrl string `json:"url"`
}

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 MessageInt interface {
	SetPluginName(name string) *messageHandle
	AddRule(rule Rule) *messageHandle
	SetWeight(weight int) *messageHandle
	AddHandle(func(ctx *Context))
}

type MetaChain

type MetaChain []*metaHandle

func (MetaChain) Len

func (m MetaChain) Len() int

func (MetaChain) Less

func (m MetaChain) Less(i, j int) bool

func (MetaChain) Swap

func (m MetaChain) Swap(i, j int)

type MetaInt

type MetaInt interface {
	SetPluginName(name string) *metaHandle
	AddRule(rule Rule) *metaHandle
	SetWeight(weight int) *metaHandle
	AddHandle(func(ctx *Context))
}

type MiraiEvent added in v1.1.6

type MiraiEvent struct {
	Type   string `json:"type"`
	QQ     int64  `json:"qq"`
	Friend struct {
		Id       int64  `json:"id"`
		NickName string `json:"nick_name"`
		Remark   string `json:"remark"`
	} `json:"friend"`
}

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 NoticeInt

type NoticeInt interface {
	SetPluginName(name string) *noticeHandle
	AddRule(rule Rule) *noticeHandle
	SetWeight(weight int) *noticeHandle
	AddHandle(func(ctx *Context))
}

type OneBotApi added in v1.1.6

type OneBotApi interface {
	Api
	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) gjson.Result
	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
}

OneBotApi @Description:

type Option added in v1.1.3

type Option struct {
	PluginName string
	Weight     int
	Block      bool
	Allies     []string
	Rules      []Rule
	CD         CoolDown
}

type Options added in v1.1.2

type Options struct {
}

type Plugin added in v1.1.1

type Plugin struct {
	Name  string
	Helps []map[string]string
	// contains filtered or unexported fields
}

Plugin @Description:

func NewPlugin added in v1.1.1

func NewPlugin(name string) *Plugin

NewPlugin *

  • @Description:
  • @param name
  • @return *Plugin
  • example

func (*Plugin) OnCommand added in v1.1.1

func (p *Plugin) OnCommand(command string, options ...Option) *commandHandle

func (*Plugin) OnConnect added in v1.1.1

func (p *Plugin) OnConnect() *connectHandle

func (*Plugin) OnDisConnect added in v1.1.1

func (p *Plugin) OnDisConnect() *disConnectHandle

func (*Plugin) OnEndWith added in v1.1.1

func (p *Plugin) OnEndWith(str string, options ...Option) *messageHandle

func (*Plugin) OnFullMatch added in v1.1.4

func (p *Plugin) OnFullMatch(match string, options ...Option) *messageHandle

func (*Plugin) OnFullMatchGroup added in v1.1.4

func (p *Plugin) OnFullMatchGroup(matchs []string, options ...Option) *messageHandle

func (*Plugin) OnKeyWords added in v1.1.1

func (p *Plugin) OnKeyWords(keyword string, options ...Option) *messageHandle

func (*Plugin) OnMessage added in v1.1.1

func (p *Plugin) OnMessage(messageType string, options ...Option) *messageHandle

func (*Plugin) OnMeta added in v1.1.1

func (p *Plugin) OnMeta() *metaHandle

func (*Plugin) OnNotice added in v1.1.1

func (p *Plugin) OnNotice(noticeType string, options ...Option) *noticeHandle

func (*Plugin) OnPretreatment added in v1.1.1

func (p *Plugin) OnPretreatment() *PretreatmentHandle

func (*Plugin) OnRegex added in v1.1.1

func (p *Plugin) OnRegex(regex string, options ...Option) *commandHandle

func (*Plugin) OnRequest added in v1.1.1

func (p *Plugin) OnRequest(requestType string, options ...Option) *requestHandle

func (*Plugin) OnStartWith added in v1.1.1

func (p *Plugin) OnStartWith(str string, options ...Option) *messageHandle

func (*Plugin) OnTime added in v1.1.1

func (p *Plugin) OnTime(crons string, selfId int, handle func(bot Api))

func (*Plugin) SetHelp added in v1.1.1

func (p *Plugin) SetHelp(help map[string]string)

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(ctx *Context) 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(ctx *Context) 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 RequestInt interface {
	SetPluginName(name string) *requestHandle
	AddRule(rule Rule) *requestHandle
	SetWeight(weight int) *requestHandle
	AddHandle(func(ctx *Context))
}

type Rule

type Rule func(ctx *Context) bool

Rule

rule类型

type Senders

type Senders struct {
	Age      int    `json:"age"`
	Area     string `json:"area"`
	Card     string `json:"card"`
	Level    string `json:"level"`
	NickName string `json:"nickname"`
	Role     string `json:"role"`
	Sex      string `json:"sex"`
	Title    string `json:"title"`
	UserId   int    `json:"user_id"`
}

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"`
}

Directories

Path Synopsis
docs
gui
Package message @Description: 用于message转换和封装的一个包
Package message @Description: 用于message转换和封装的一个包
Package utils @Description: Package utils @Description:
Package utils @Description: Package utils @Description:

Jump to

Keyboard shortcuts

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