bot

package
v0.0.0-...-c0b23b6 Latest Latest
Warning

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

Go to latest
Published: Oct 8, 2022 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// 信息种类
	MsgPostType = "message"
	ReqPostType = "request"
	NtsPostType = "notice"
	MtaPostType = "meta_event"

	PriMsgType = "private"
	GruMsgType = "group"

	FriSubMsgType  = "friend"
	GruSubMsgType  = "group"
	GrusSubMsgType = "group_self"
	NorSubMsgType  = "normal"
	AoySubMsgType  = "anonymous" // 匿名
	NtsSubMsgType  = "notice"    // 群内禁止私聊的通告

	FriRequestType = "friend"
	GruRequestType = "group"

	GruUplNtsType = "group_upload"
	GruAdmNtsType = "group_admin"
	GruDecNtsType = "group_decrease"
	GruIncNtsType = "group_increase"
	GruBanNtsType = "group_ban"
	GruRecNtsType = "group_recall"
	GruCadNtsType = "group_card"
	FriAddNtsType = "friend_add"
	FriRecNtsType = "friend_recall"
	OffLinNtsType = "offline_file"
	CliStuNtsType = "client_status"
	EssNtsType    = "essence"
	NotifyNtsType = "notify"

	HonNotifySubType = "honor"
	PokNotifySubType = "poke"

	OwnRoleType = "owner"
	AdmRoleType = "admin"
	MebRoleType = "member"
)

receive

View Source
const (
	MsgSendApi   = "send_msg"
	MsgDeleteApi = "delete_msg"

	GetImgApi          = "get_image"
	GetBotInfo         = "get_login_info"
	GetStrangerInfoApi = "get_stranger_info"

	GroupKickApi  = "set_group_kick"
	GroupBanApi   = "set_group_ban"
	GroupCardApi  = "set_group_card"
	GroupLeaveApi = "set_group_leave"
	GruRequestApi = "set_group_add_request"
	GruGetListApi = "get_group_list"

	FriDelApi     = "delete_friend"
	FriRequestApi = "set_friend_add_request"
	FriGetListApi = "get_friend_list"

	CanSendImgApi = "can_send_image"
)

send thing

Variables

View Source
var (
	DefaultBotConfig *botConfig
)
View Source
var PluginMgr *pluginManager

Functions

This section is empty.

Types

type Asender

type Asender struct {
	// base
	UserId   int64  `json:"user_id"`
	Nickname string `json:"nickname"`
	Sex      string `json:"sex"`
	Age      int32  `json:"age"`
	// group
	Cardname string `json:"card"`
	Area     string `json:"area"`
	Level    string `json:"level"`
	Role     string `json:"role"`
	Title    string `json:"title"`
}

func (*Asender) String

func (sd *Asender) String() string

type Bot

type Bot struct {
	HasBoot bool
	Info    QQInfo
	// contains filtered or unexported fields
}

func NewBot

func NewBot() *Bot

func (*Bot) Close

func (bot *Bot) Close()

关闭websocket 连接

func (*Bot) QuickTalk

func (bot *Bot) QuickTalk(action string, v interface{}) ([]byte, error)

快速反应,发送请求,接收json 的 []byte, 如果有错误会返回error 第一个参数是api的url,第二个参数是请求的 params struct

func (*Bot) Send

func (bot *Bot) Send(action string, v interface{}) error

发送请求, 不处理响应信息, 如果发送失败会返回error 第一个参数是api的url,第二个参数是请求的 params struct

func (*Bot) Start

func (bot *Bot) Start()

连接 websocket

func (*Bot) Work

func (bot *Bot) Work()

bot 开始接收消息

type BotPlugin

type BotPlugin interface {
	GetType() string
	Init()
	Action(b *Bot, v interface{})
	Destroy()
}

type MsgSend

type MsgSend struct {
	MessageType string `json:"message_type"`
	UserId      int64  `json:"user_id"`
	GroupId     int64  `json:"group_id"`
	Message     string `json:"message"`
}

type QQInfo

type QQInfo struct {
	UserId   int64  `json:"user_id"`
	NickName string `json:"nickname"`
}

type RecvKind

type RecvKind struct {
	PostType string `json:"post_type"`
}

type RecvMessage

type RecvMessage struct {
	Sender      Asender `json:"sender"`
	SubType     string  `json:"sub_type"`
	TempSource  string  `json:"temp_source"`
	MessageType string  `json:"message_type"`
	GroupId     int64   `json:"group_id"`
	Message     string  `json:"message"`
}

func (*RecvMessage) Analyze

func (revm *RecvMessage) Analyze() ([]string, []map[string]string)

func (*RecvMessage) String

func (msg *RecvMessage) String() string

type RecvMeta

type RecvMeta struct {
	MetaEvenType string `json:"meta_event_type"`
	SubType      string `json:"sub_type"`
}

func (*RecvMeta) String

func (meta *RecvMeta) String() string

type RecvNotice

type RecvNotice struct {
	NoticeType string `json:"notice_type"`
	SubType    string `json:"sub_type"`
	SenderId   int64  `json:"sender_id"`
	TargetId   int64  `json:"target_id"`
	GroupId    int64  `json:"group_id"`
}

func (*RecvNotice) String

func (nts *RecvNotice) String() string

type RecvRequest

type RecvRequest struct {
	RequestType string `json:"request_type"`
	GroupId     int64  `json:"group_id"`
	UserId      int64  `json:"user_id"`
	Flag        string `json:"flag"`
	SubType     string `json:"sub_type"`
}

func (*RecvRequest) String

func (req *RecvRequest) String() string

type SendRespondJson

type SendRespondJson struct {
	Action string      `json:"action"`
	Params interface{} `json:"params"`
	Echo   string      `json:"echo"`
}

Jump to

Keyboard shortcuts

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