go_mybots

package module
v0.0.0-...-41a911c Latest Latest
Warning

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

Go to latest
Published: Sep 12, 2021 License: AGPL-3.0 Imports: 11 Imported by: 0

README

go-mybots

该项目已不再维护,请查看作者的另一个项目leafBot

go进行onebot的http简单实现

基本使用

首先需要一个qq无头客户端和一个go运行环境。

go语言下载官网 !!国内可访问https://studygolang.com/dl下载

这里以go-cqhttp为例,go-cqhttp配置详情见原文档 首先下载go-cqhttp发行版,然后解压后打开exe文件,第一次打开会生成配置文件。然后打开config.hjson文件,旧版为config.json。 然后配置基本的bot所使用的qq号和密码。除此还需要配置。

    http_config: {
        // 是否启用正向HTTP服务器
        enabled: true
        // 服务端监听地址
        host: 
        // 服务端监听端口
        port: 
        // 反向HTTP超时时间, 单位秒
        // 最小值为5,小于5将会忽略本项设置
        timeout: 0
        // 反向HTTP POST地址列表
        // 格式: 
        // {
        //    地址: secret
        // }
        post_urls: {}

enable设置为true,host和port是go-cqhttp所监听的ip和端口,post_url为go-cqhttp事件上报地址,注意post_urls填写格式。

go get github.com/3343780376/go-mybots

创建一个项目,main.go

import (
	"github.com/3343780376/go-mybots"
	"log"
)

//实例化一个Bot对象,参数为go-cqhttp监听的地址和端口,以及你的作为测试给bot发信息的账号
var Bot = go_mybots.Bots{Address: "127.0.0.1", Port: 5700,Admin: 1743224847}

//将handle函数加入go_mybots的消息路由
func init(){
    o_mybots.ViewMessage = append(go_mybots.ViewMessage, go_mybots.ViewMessageApi{OnMessage: hand,
    		MessageType: go_mybots.MessageTypeApi.Group, SubType: ""})
}

func main() {
	hand := go_mybots.Hand()
	err := hand.Run("127.0.0.1:8000")  //设置该项目监听地址,及为go-cqhttp的上报地址
	if err != nil {
		log.Println(err.Error())
	}
}

//event参数为上报的消息,详情可参考onebot文档
func handle(event go-mybots.events){
    //判断消息为hello且发送消息的账号为测试账号
    if event.Message=="hello"&&event.UserId== Bot.Admin {
            //异步调用SendPrivateMsg这个api,三个参数分别为,发送的对象qq号,消息内容和是否解析cq码
    		go Bot.SendPrivateMsg(event.UserId,"hello,world",false)
    	}
}

此时使用测试的qq号给bot发送hello,即可看到

具体实现更多的逻辑,可先参考onebot文档

Documentation

Overview

api.go文件包含了可以调用的各个api

event.go为对各种event事件进行处理

Index

Constants

This section is empty.

Variables

View Source
var (

	//MessageSubTypeApi = ConstMessageSubType{
	//	Friend: "friend",
	//	Group: "group",
	//	Other: "other",
	//	Normal: "normal",
	//	Anonymous: "anonymous",
	//	Notice: "notice"}
	NoticeTypeApi = ConstNoticeType{
		GroupUpload:   "group_upload",
		GroupAdmin:    "group_admin",
		GroupDecrease: "group_decrease",
		GroupIncrease: "group_increase",
		GroupBan:      "group_ban",
		FriendAdd:     "friend_add",
		GroupRecall:   "group_recall",
		FriendRecall:  "friend_recall",
		Notify:        "notify",
		OfflineFile:   "offline_file",
		GroupCard:     "group_card"}

	MessageTypeApi = ConstMessageType{
		Group:   "group",
		Private: "private"}
)
View Source
var (
	LoginInfoJson       responseLoginIndoJson
	StrangerInfo        responseStrangerInfoJson
	FriendListJson      responseFriendListJson
	GroupInfoJson       responseGroupInfoJson
	GroupListJson       responseGroupListJson
	GroupMemberInfoJson responseGroupMemberInfoJson
	GroupMemberListJson responseGroupMemberListJson
	GroupHonorInfoJson  responseGroupHonorInfoJson
	CookiesJson         responseCookiesJson
)
View Source
var (
	Fil             = Filter{}
	ViewMessage     []ViewMessageApi     //ViewMessage为一个需要上报到各个Message事件的切片
	ViewNotice      []ViewOnNoticeApi    //ViewNotice为一个需要上报到各个Notice事件的切片
	ViewRequest     []MessageFun         //ViewRequest为一个需要上报到各个Request事件的切片
	ViewMeta        []MessageFun         //ViewMeta为一个需要上报到各个Meta事件的切片
	ViewOnCoCommand []ViewOnC0CommandApi //ViewOnCommand为一个需要上报到各个Command事件的切片
	Info            LoginInfo            //Info为当前账号的信息

)

Functions

func Hand

func Hand() *gin.Engine

Types

type Api

type Api interface {
	SendGroupMsg(groupId int, message string, autoEscape bool) (int32, error)
	SendPrivateMsg(userId int, message string, autoEscape bool) (int32, error)
	DeleteMsg(messageId int32) error
	GetMsg(messageId int32) (GetMessage, error)
	SetGroupBan(groupId int, userId int, duration int) error
	SetGroupCard(groupId int, userId int, card string) error
	SendMsg(messageType string, userId int, groupId int, message string, autoEscape bool) (int32, error)
	SendLike(userId int, times int) error
	SetGroupKick(groupId int, UserId int, rejectAddRequest bool) error
	SetGroupAnonymousBan(groupId int, flag string, duration int) error
	SetGroupWholeBan(groupId int, enable bool) error
	SetGroupAdmin(groupId int, UserId int, enable bool) error
	SetGroupAnonymous(groupId int, enable bool) error
	SetGroupName(groupId int, groupName string) error
	SetGroupLeave(groupId int, isDisMiss bool) error
	SetGroupSpecialTitle(groupId int, userId int, specialTitle string, duration int) error
	SetFriendAddRequest(flag string, approve bool, remark string) error
	SetGroupAddRequest(flag string, subType string, approve bool, reason string) error
	GetLoginInfo() (LoginInfo, error)
	GetStrangerInfo() (Senders, error)
	GetFriendList() ([]FriendList, error)
	GetGroupInfo(groupId int, noCache bool) (GroupInfo, error)
	GetGroupList() ([]GroupInfo, error)
	GetGroupMemberInfo(groupId int, UserId int, noCache bool) (GroupMemberInfo, error)
	GetGroupMemberList(groupId int) ([]GroupMemberInfo, error)
	GetGroupHonorInfo(groupId int, honorType string) (GroupHonorInfo, error)
	GetCookies(domain string) (Cookie, error)
	GetCsrfToken() (CsrfToken, error)
	GetCredentials(domain string) (Credentials, error)
	GetRecord(file, outFormat string) (Record, error)
	GetImage(file string) (Image, error)
	CanSendImage() (Bool, error)
	CanSendRecord() (Bool, error)
	GetStatus() (OnlineStatus, error)
	SetRestart(delay int)
	CleanCache()
}

type Bool

type Bool struct {
	Yes bool `json:"yes"`
}

type Bots

type Bots struct {
	Address string
	Port    int
	Admin   int
}

func (Bots) CanSendImage

func (bot Bots) CanSendImage() (Bool, error)

func (Bots) CanSendRecord

func (bot Bots) CanSendRecord() (Bool, error)

func (Bots) CleanCache

func (bot Bots) CleanCache()

func (Bots) DeleteMsg

func (bot Bots) DeleteMsg(messageId int32) error

func (Bots) DownloadFile

func (bot Bots) DownloadFile(url string, threadCount int, headers []string) (DownloadFilePath, error)

func (Bots) GetCookies

func (bot Bots) GetCookies(domain string) (Cookie, error)

func (Bots) GetCredentials

func (bot Bots) GetCredentials(domain string) (Credentials, error)

func (Bots) GetCsrfToken

func (bot Bots) GetCsrfToken() (CsrfToken, error)

func (Bots) GetForwardMsg

func (bot Bots) GetForwardMsg(messageId int) ([]ForwardMsg, error)

func (Bots) GetFriendList

func (bot Bots) GetFriendList() ([]FriendList, error)

func (Bots) GetGroupAtAllRemain

func (bot Bots) GetGroupAtAllRemain(groupId int) (GroupAtAllRemain, error)

func (Bots) GetGroupFileSystemInfo

func (bot Bots) GetGroupFileSystemInfo(groupId int) (GroupFileSystemInfo, error)

func (Bots) GetGroupFileUrl

func (bot Bots) GetGroupFileUrl(groupId int, fileId string, busid int) (fileUrl, error)

func (Bots) GetGroupFilesByFolder

func (bot Bots) GetGroupFilesByFolder(groupId int, folderId string) (GroupFilesByFolder, error)

func (Bots) GetGroupHonorInfo

func (bot Bots) GetGroupHonorInfo(groupId int, honorType string) (GroupHonorInfo, error)

func (Bots) GetGroupInfo

func (bot Bots) GetGroupInfo(groupId int, noCache bool) (GroupInfo, error)

func (Bots) GetGroupList

func (bot Bots) GetGroupList() ([]GroupInfo, error)

func (Bots) GetGroupMemberInfo

func (bot Bots) GetGroupMemberInfo(groupId int, UserId int, noCache bool) (GroupMemberInfo, error)

func (Bots) GetGroupMemberList

func (bot Bots) GetGroupMemberList(groupId int) ([]GroupMemberInfo, error)

func (Bots) GetGroupMsgHistory

func (bot Bots) GetGroupMsgHistory(messageSeq int64, groupId int) (MessageHistory, error)

func (Bots) GetGroupRootFiles

func (bot Bots) GetGroupRootFiles(groupId int) (GroupRootFiles, error)

func (Bots) GetGroupSystemMsg

func (bot Bots) GetGroupSystemMsg() (GroupSystemMsg, error)

func (Bots) GetImage

func (bot Bots) GetImage(file string) (Image, error)

func (Bots) GetLoginInfo

func (bot Bots) GetLoginInfo() (LoginInfo, error)

func (Bots) GetMsg

func (bot Bots) GetMsg(messageId int32) (GetMessage, error)

func (Bots) GetMsgSpecial

func (bot Bots) GetMsgSpecial(messageId int) (MsgData, error)

func (Bots) GetNextEvent

func (bot Bots) GetNextEvent(n, UserId int) Event

GetNextEvent方法 int n: 需要等待多少个事件之后放弃获取该事件 int UserId: 需要获取的信息对应的qq账号

return: Message类型的Event

func (Bots) GetOnlineClients

func (bot Bots) GetOnlineClients(noCache bool) (Clients, error)

func (Bots) GetRecord

func (bot Bots) GetRecord(file, outFormat string) (Record, error)

func (Bots) GetStatus

func (bot Bots) GetStatus() (OnlineStatus, error)

func (Bots) GetStrangerInfo

func (bot Bots) GetStrangerInfo() (Senders, error)

func (Bots) GetVipInfoTest

func (bot Bots) GetVipInfoTest(UserId int) (VipInfo, error)

func (Bots) GetWordSlices

func (bot Bots) GetWordSlices(content string) ([]string, error)

func (Bots) OcrImage

func (bot Bots) OcrImage(image string) (OcrImage, error)

func (Bots) ReloadEventFilter

func (bot Bots) ReloadEventFilter() error

func (Bots) SendGroupForwardMsg

func (bot Bots) SendGroupForwardMsg(groupId int, messages []Node) error

func (Bots) SendGroupMsg

func (bot Bots) SendGroupMsg(groupId int, message string, autoEscape bool) (int32, error)

func (Bots) SendGroupNotice

func (bot Bots) SendGroupNotice(groupId int64, content string) error

func (Bots) SendLike

func (bot Bots) SendLike(userId int, times int) error

func (Bots) SendMsg

func (bot Bots) SendMsg(messageType string, userId int, groupId int, message string, autoEscape bool) (int32, error)

func (Bots) SendPrivateMsg

func (bot Bots) SendPrivateMsg(userId int, message string, autoEscape bool) (int32, error)

func (Bots) SetFriendAddRequest

func (bot Bots) SetFriendAddRequest(flag string, approve bool, remark string) error

func (Bots) SetGroupAddRequest

func (bot Bots) SetGroupAddRequest(flag string, subType string, approve bool, reason string) error

func (Bots) SetGroupAdmin

func (bot Bots) SetGroupAdmin(groupId int, UserId int, enable bool) error

func (Bots) SetGroupAnonymous

func (bot Bots) SetGroupAnonymous(groupId int, enable bool) error

func (Bots) SetGroupAnonymousBan

func (bot Bots) SetGroupAnonymousBan(groupId int, flag string, duration int) error

func (Bots) SetGroupBan

func (bot Bots) SetGroupBan(groupId int, userId int, duration int) error

func (Bots) SetGroupCard

func (bot Bots) SetGroupCard(groupId int, userId int, card string) error

func (Bots) SetGroupKick

func (bot Bots) SetGroupKick(groupId int, UserId int, rejectAddRequest bool) error

func (Bots) SetGroupLeave

func (bot Bots) SetGroupLeave(groupId int, isDisMiss bool) error

func (Bots) SetGroupName

func (bot Bots) SetGroupName(groupId int, groupName string) error

func (Bots) SetGroupNameSpecial

func (bot Bots) SetGroupNameSpecial(groupId int, groupName string) error

func (Bots) SetGroupPortrait

func (bot Bots) SetGroupPortrait(groupId int, file string, cache int) error

func (Bots) SetGroupSpecialTitle

func (bot Bots) SetGroupSpecialTitle(groupId int, userId int, specialTitle string, duration int) error

func (Bots) SetGroupWholeBan

func (bot Bots) SetGroupWholeBan(groupId int, enable bool) error

func (Bots) SetRestart

func (bot Bots) SetRestart(delay int)

func (Bots) UploadGroupFile

func (bot Bots) UploadGroupFile(groupId int, file string, name string, folder string) error

type Clients

type Clients struct {
	Clients []Device `json:"clients"` //在线客户端列表
}

type CommandFun

type CommandFun func(event Event, args []string)

type ConstMessageType

type ConstMessageType struct {
	Group   string
	Private string
}

type ConstNoticeType

type ConstNoticeType struct {
	GroupUpload   string //群文件上传
	GroupAdmin    string //群管理员变动
	GroupDecrease string //群成员减少
	GroupIncrease string //群成员增加
	GroupBan      string //群禁言
	FriendAdd     string //好友添加
	GroupRecall   string //群消息撤回
	FriendRecall  string //好友消息撤回
	Notify        string //群内戳一戳,群红包运气王,群成员荣誉变更,好友戳一戳
	GroupCard     string //群成员名片更新
	OfflineFile   string //接收到离线文件
}

type Content

type Content struct {
	Type string `json:"type"`
	Data string `json:"data"`
}
type Cookie struct {
	Cookies string `json:"cookies"`
}

type Credentials

type Credentials struct {
	Cookie
	CsrfToken
}

type CsrfToken

type CsrfToken struct {
	Token string `json:"token"`
}

type CurrentTalkativeS

type CurrentTalkativeS struct {
	UserId   int    `json:"user_id"`
	NickName string `json:"nick_name"`
	Avatar   string `json:"avatar"`
	DayCount int    `json:"day_count"`
}

type Device

type Device struct {
	AppId      int64  `json:"app_id"`      //客户端ID
	DeviceName string `json:"device_name"` //设备名称
	DeviceKind string `json:"device_kind"` //设备类型
}

type DownloadFilePath

type DownloadFilePath struct {
	File string `json:"file"`
}

type Event

type Event struct {
	Anonymous     anonymous `json:"anonymous"`
	Font          string    `json:"font"`
	GroupId       int       `json:"group_id"`
	Message       string    `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        string    `json:"status"`
	Interval      string    `json:"interval"`
	CardNew       string    `json:"card_new"` //新名片
	CardOld       string    `json:"card_old"` //旧名片
	MessageIds
}

type File

type File struct {
	FileId        string `json:"file_id"`        //文件ID
	FileName      string `json:"file_name"`      //文件名
	Busid         int    `json:"busid"`          //文件类型
	FileSize      int64  `json:"file_size"`      //文件大小
	UploadTime    int64  `json:"upload_time"`    //上传时间
	DeadTime      int64  `json:"dead_time"`      //过期时间,永久文件恒为0
	ModifyTime    int64  `json:"modify_time"`    //最后修改时间
	DownloadTimes int32  `json:"download_times"` //下载次数
	Uploader      int64  `json:"uploader"`       //上传者ID
	UploaderName  string `json:"uploader_name"`  //上传者名字
}

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 Filter

type Filter struct {
	Group   FilterGroup `json:"group"`
	Private []FilterNum `json:"private"`
}

func LoadFilter

func LoadFilter(path string) Filter

type FilterGroup

type FilterGroup struct {
	UserId  []FilterNum `json:"userId"`
	GroupId []FilterNum `json:"groupId"`
}

type FilterNum

type FilterNum struct {
	Num int `json:"num"`
}

type Folder

type Folder struct {
	FolderId       string `json:"folder_id"`        //文件夹ID
	FolderName     string `json:"folder_name"`      //文件名
	CreateTime     int    `json:"create_time"`      //创建时间
	Creator        int    `json:"creator"`          //创建者
	CreatorName    string `json:"creator_name"`     //创建者名字
	TotalFileCount int32  `json:"total_file_count"` //子文件数量
}

type ForwardMsg

type ForwardMsg struct {
	Content string  `json:"content"`
	Sender  Senders `json:"sender"`
	Time    int     `json:"time"`
}

type FriendList

type FriendList struct {
	UserId   int    `json:"user_id"`
	NickName string `json:"nick_name"`
	Remark   string `json:"remark"`
}

type GetMessage

type GetMessage struct {
	Time      int32   `json:"time"`
	Group     bool    `json:"group"`
	MessageId int32   `json:"message_id"`
	RealId    int32   `json:"real_id"`
	Sender    Senders `json:"sender"`
	Message   string  `json:"message"`
}

type GroupAtAllRemain

type GroupAtAllRemain struct {
	CanAtAll                 bool `json:"can_at_all"`                    //是否可以@全体成员
	RemainAtAllCountForGroup int  `json:"remain_at_all_count_for_group"` //群内所有管理当天剩余@全体成员次数
	RemainAtAllCountForUin   int  `json:"remain_at_all_count_for_uin"`   //BOT当天剩余@全体成员次数
}

type GroupFileSystemInfo

type GroupFileSystemInfo struct {
	FileCount  int `json:"file_count"`  //文件总数
	LimitCount int `json:"limit_count"` //文件上限
	UsedSpace  int `json:"used_space"`  //已使用空间
	TotalSpace int `json:"total_space"` //空间上限
}

type GroupFilesByFolder

type GroupFilesByFolder struct {
	Files   []File   `json:"files"`
	Folders []Folder `json:"folders"`
}

type GroupHonorInfo

type GroupHonorInfo struct {
	GroupId          int                  `json:"group_id"`
	CurrentTalkative CurrentTalkativeS    `json:"current_talkative"`
	TalkativeList    []GroupHonorInfoList `json:"talkative_list"`
	PerformerList    []GroupHonorInfoList `json:"performer_list"`
	LegendList       []GroupHonorInfoList `json:"legend_list"`
	StrongNewbieList []GroupHonorInfoList `json:"strong_newbie_list"`
	EmotionList      []GroupHonorInfoList `json:"emotion_list"`
}

type GroupHonorInfoList

type GroupHonorInfoList struct {
	UserId      int    `json:"user_id"`
	NickName    string `json:"nick_name"`
	Avatar      string `json:"avatar"`
	Description string `json:"description"`
}

type GroupInfo

type GroupInfo struct {
	GroupId        int    `json:"group_id"`
	GroupName      string `json:"group_name"`
	MemberCount    int    `json:"member_count"`
	MaxMemberCount int    `json:"max_member_count"`
}

type GroupMemberInfo

type GroupMemberInfo struct {
	GroupId         int  `json:"group_id"`
	JoinTime        int  `json:"join_time"`
	LastSentTime    int  `json:"last_sent_time"`
	Unfriendly      bool `json:"unfriendly"`
	TitleExpireTime int  `json:"title_expire_time"`
	CardChangeable  bool `json:"card_changeable"`
	Senders
}

type GroupRootFiles

type GroupRootFiles struct {
	Files   []File   `json:"files"`
	Folders []Folder `json:"folders"`
}

type GroupSystemMsg

type GroupSystemMsg struct {
	InvitedRequests []InvitedRequest `json:"invited_requests"` //邀请消息列表
	JoinRequests    []JoinRequest    `json:"join_requests"`    //进群消息列表
}

type Image

type Image struct {
	File string `json:"file"`
}

type IncreaseApi

type IncreaseApi interface {
	DownloadFile(url string, threadCount int, headers []string) (DownloadFilePath, error)
	GetGroupMsgHistory(messageSeq int64, groupId int) (MessageHistory, error)
	GetOnlineClients(noCache bool) (Clients, error)
	GetVipInfoTest(UserId int) (VipInfo, error)
	SendGroupNotice(groupId int64, content string) error
	ReloadEventFilter() error
	UploadGroupFile(groupId int, file string, name string, folder string) error
}

go-cqhttp新增api

type InvitedRequest

type InvitedRequest struct {
	RequestId   int    `json:"request_id"`   //请求ID
	InvitorUin  int    `json:"invitor_uin"`  //邀请者
	InvitorNick string `json:"invitor_nick"` //邀请者昵称
	GroupId     int    `json:"group_id"`     //群号
	GroupName   string `json:"group_name"`   //群名
	Checked     bool   `json:"checked"`      //是否已被处理
	Actor       int64  `json:"actor"`        //处理者, 未处理为0
}

type JoinRequest

type JoinRequest struct {
	RequestId     int    `json:"request_id"`     //请求ID
	RequesterUin  int    `json:"requester_uin"`  //请求者ID
	RequesterNick string `json:"requester_nick"` //请求者昵称
	Message       string `json:"message"`        //验证消息
	GroupId       int    `json:"group_id"`       //群号
	GroupName     string `json:"group_name"`     //群名
	Checked       bool   `json:"checked"`        //是否已被处理
	Actor         int    `json:"actor"`          //处理者, 未处理为0
}

type LoginInfo

type LoginInfo struct {
	UserId   int    `json:"user_id"`
	NickName string `json:"nick_name"`
}

type Message

type Message struct {
	Message string `json:"message"`
}

func MessageAt

func MessageAt(UserId int) Message

type MessageFun

type MessageFun func(event Event)

type MessageHistory

type MessageHistory struct {
	Messages []string `json:"messages"`
}

type MessageIds

type MessageIds struct {
	MessageId int32 `json:"message_id"`
}

type MsgData

type MsgData struct {
	MessageId int     `json:"message_id"`
	RealId    int     `json:"real_id"`
	Sender    Senders `json:"sender"`
	Time      int     `json:"time"`
	Message   string  `json:"message"`
}

type Node

type Node struct {
	Id      int     `json:"id"`
	Name    string  `json:"name"`
	Uin     int     `json:"uin"`
	Content Content `json:"content"`
}

type OcrImage

type OcrImage struct {
	Texts    []TextDetection `json:"texts"`
	Language string          `json:"language"`
}

type OnlineStatus

type OnlineStatus struct {
	Online bool `json:"online"`
	Good   bool `json:"good"`
}

type Record

type Record struct {
	File      string `json:"file"`
	OutFormat string `json:"out_format"`
}

type Reflect

type Reflect interface {
	GetNextEvent(int, int) Event
}

type Rule

type Rule struct {
	// contains filtered or unexported fields
}

Rule结构体两个成员分别为RuleCheck类型的函数和需要传递的参数

type RuleCheck

type RuleCheck struct {
}

func (RuleCheck) EndWith

func (rule RuleCheck) EndWith(event Event, s string) bool

EndWith方法判断该消息是否以某个字符串结尾 args:

string s: 需要判断的字符串

func (RuleCheck) OnlyToMe

func (rule RuleCheck) OnlyToMe(event Event) bool

OnlyToMe方法为一个RuleChecked方法 判断该事件如果在群聊中是否艾特机器人 如果时私聊信息,直接返回True

func (RuleCheck) StartWith

func (rule RuleCheck) StartWith(event Event, s string) bool

StartWith方法判断该消息是否以某个字符串开头 args:

string s: 需要判断的字符串

type RuleCheckIn

type RuleCheckIn interface {
	OnlyToMe(event Event) bool
	StartWith(event Event, s string) bool
	EndWith(event Event, s string) bool
}

RuleCheckIn为RuleCheck结构体的实现

type Senders

type Senders struct {
	Age      string `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 SpecialApi

type SpecialApi interface {
	SetGroupNameSpecial(groupId int, groupName string) error
	SetGroupPortrait(groupId int, file string, cache int) error
	GetMsgSpecial(messageId int) (MsgData, error)
	GetForwardMsg(messageId int) ([]ForwardMsg, error)
	SendGroupForwardMsg(groupId int, messages []Node) error
	GetWordSlices(content string) ([]string, error)
	OcrImage(image string) (OcrImage, error)
	GetGroupSystemMsg() (GroupSystemMsg, error)
	GetGroupFileSystemInfo(groupId int) (GroupFileSystemInfo, error)
	GetGroupRootFiles(groupId int) (GroupRootFiles, error)
	GetGroupFilesByFolder(groupId int, folderId string) (GroupFilesByFolder, error)
	GetGroupFileUrl(groupId int, fileId string, busid int) (fileUrl, error)
	GetGroupAtAllRemain(groupId int) (GroupAtAllRemain, error)
}

type TextDetection

type TextDetection struct {
	Text        string      `json:"text"`
	Confidence  int         `json:"confidence"`
	Coordinates interface{} `json:"coordinates"`
}

type ViewMessageApi

type ViewMessageApi struct {
	OnMessage   MessageFun
	MessageType string
	SubType     string
}

ViewMessageApi结构体为一个Message消息上报位置,包含了具体的方法和需要传递的Message的MessageType和SubType

type ViewOnC0CommandApi

type ViewOnC0CommandApi struct {
	CoCommand   CommandFun
	Command     string
	Allies      string
	RuleChecked []Rule
}

ViewOnCommandApi结构体为一个Command上报位置,包含了具体的方法和该命令的具体命令以及别名,RuleChecked为一个Rule切片,

type ViewOnNoticeApi

type ViewOnNoticeApi struct {
	OnNotice   MessageFun
	NoticeType string
	SubType    string
}

ViewOnNoticeApi结构体为一个Notice上报位置,包含了具体的方法和需要传递的Notice的NoticeType和SubType

type VipInfo

type VipInfo struct {
	UserId         int64   `json:"user_id"`          //QQ 号
	Nickname       string  `json:"nickname"`         //用户昵称
	Level          int64   `json:"level"`            //QQ 等级
	LevelSpeed     float64 `json:"level_speed"`      //等级加速度
	VipLevel       string  `json:"vip_level"`        //会员等级
	VipGrowthSpeed int64   `json:"vip_growth_speed"` //会员成长速度
	VipGrowthTotal int64   `json:"vip_growth_total"` //会员成长总值
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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