mirai

package module
v0.0.4 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2023 License: Apache-2.0 Imports: 12 Imported by: 1

README

Mirai

Release License

Install

GoVersion

go get -u github.com/starudream/mirai-go

Usage

GoDoc

Ref

API

License

Apache License 2.0

Documentation

Index

Constants

View Source
const (
	SexUnknown = "UNKNOWN"
	SexMale    = "MALE"
	SexFemale  = "FEMALE"
)
View Source
const (
	DefaultUserAgent = "starudream-mirai-go"
)

Variables

This section is empty.

Functions

func Debug

func Debug() bool

Types

type AboutInfo

type AboutInfo struct {
	Version string `json:"version"`
}

type AboutResp

type AboutResp struct {
	BaseResp
	Data AboutInfo `json:"data"`
}

type BaseReq

type BaseReq struct {
	SessionKey string `url:"sessionKey,omitempty" json:"sessionKey,omitempty"`
}

func (BaseReq) GetSessionKey

func (req BaseReq) GetSessionKey() string

type BaseReqInterface

type BaseReqInterface interface {
	GetSessionKey() string
}

type BaseResp

type BaseResp struct {
	Code Code   `json:"code,omitempty"`
	Msg  string `json:"msg,omitempty"`
}

func (BaseResp) GetCode

func (resp BaseResp) GetCode() Code

func (BaseResp) GetMsg

func (resp BaseResp) GetMsg() string

type BaseRespInterface

type BaseRespInterface interface {
	GetCode() Code
	GetMsg() string
}

type BindReq

type BindReq struct {
	BaseReq
	QQ int64 `json:"qq"`
}

type BotListResp

type BotListResp struct {
	BaseResp
	Data []int64 `json:"data"`
}

type BotProfileReq

type BotProfileReq struct {
	BaseReq
}

type Client

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

func NewClient

func NewClient(addr, verifyKey string, options ...ClientOptionFunc) (*Client, error)

func (*Client) About

func (c *Client) About() (AboutInfo, *http.Response, error)

func (*Client) Bind

func (c *Client) Bind(req BindReq) (*http.Response, error)

func (*Client) BotList

func (c *Client) BotList() ([]int64, *http.Response, error)

func (*Client) BotProfile

func (c *Client) BotProfile(req BotProfileReq) (ProfileResp, *http.Response, error)

func (*Client) CountMessage

func (c *Client) CountMessage(req CountMessageReq) (int, *http.Response, error)

func (*Client) Exec

func (c *Client) Exec(method, path string, opt, res any) (*resty.Response, error)

func (*Client) FetchLatestMessage

func (c *Client) FetchLatestMessage(req GetMessageReq) (Messages, *http.Response, error)

func (*Client) FetchMessage

func (c *Client) FetchMessage(req GetMessageReq) (Messages, *http.Response, error)

func (*Client) FriendProfile

func (c *Client) FriendProfile(req FriendProfileReq) (ProfileResp, *http.Response, error)

func (*Client) PeakLatestMessage

func (c *Client) PeakLatestMessage(req GetMessageReq) (Messages, *http.Response, error)

func (*Client) PeakMessage

func (c *Client) PeakMessage(req GetMessageReq) (Messages, *http.Response, error)

func (*Client) Pre

func (c *Client) Pre(method, path string, opt any) (string, map[string]string, any, error)

func (*Client) Release

func (c *Client) Release(req ReleaseReq) (*http.Response, error)

func (*Client) SendFriendMessage

func (c *Client) SendFriendMessage(req SendMessageReq) (int64, *http.Response, error)

func (*Client) SendGroupMessage

func (c *Client) SendGroupMessage(req SendMessageReq) (int64, *http.Response, error)

func (*Client) SendTempMessage

func (c *Client) SendTempMessage(req SendMessageReq) (int64, *http.Response, error)

func (*Client) SessionInfo

func (c *Client) SessionInfo(req SessionInfoReq) (SessionInfoQQ, *http.Response, error)

func (*Client) Verify

func (c *Client) Verify() (string, *http.Response, error)

type ClientOptionFunc

type ClientOptionFunc func(c *Client) error

func WithClient added in v0.0.3

func WithClient(client *resty.Client) ClientOptionFunc

func WithUserAgent

func WithUserAgent(userAgent string) ClientOptionFunc

type Code

type Code int
const (
	CodeOK             Code = 0
	CodeWrongVerifyKey Code = 1
	CodeBotNotExists   Code = 2
	CodeInvalidSession Code = 3
	CodeUnauthorized   Code = 4
	CodeTargetNotFound Code = 5
	CodeFileNotFound   Code = 6
	CodeNoPermission   Code = 10
	CodeBotMuted       Code = 20
	CodeMessageTooLong Code = 30
	CodeInvalidArgs    Code = 400
)

func (Code) Equal

func (c Code) Equal(code Code) bool

func (Code) String

func (c Code) String() string

type CountMessageReq

type CountMessageReq struct {
	BaseReq
}

type CountMessageResp

type CountMessageResp struct {
	BaseResp
	Data int `json:"data"`
}

type FriendProfileReq

type FriendProfileReq struct {
	BaseReq
	Target int64 `url:"target,omitempty" json:"target,omitempty"`
}

type GetMessageReq

type GetMessageReq struct {
	BaseReq
	Count int `url:"count,omitempty" json:"count,omitempty"`
}

type GetMessageResp

type GetMessageResp struct {
	BaseResp
	Data Messages `json:"data"`
}

type Message

type Message struct {
	Type MessageType `json:"-"`
	// contains filtered or unexported fields
}

func (*Message) MarshalJSON

func (v *Message) MarshalJSON() ([]byte, error)

func (*Message) UnmarshalJSON

func (v *Message) UnmarshalJSON(raw []byte) error

type MessageInfoAt added in v0.0.4

type MessageInfoAt struct {
	Type    MessageInfoType `json:"type"`
	Target  int64           `json:"target"`
	Display string          `json:"display,omitempty"`
}

type MessageInfoAtAll added in v0.0.4

type MessageInfoAtAll struct {
	Type MessageInfoType `json:"type"`
}

type MessageInfoInterface

type MessageInfoInterface interface {
	// contains filtered or unexported methods
}

type MessageInfoPlain

type MessageInfoPlain struct {
	Type MessageInfoType `json:"type"`
	Text string          `json:"text"`
}

type MessageInfoSource added in v0.0.4

type MessageInfoSource struct {
	Type MessageInfoType `json:"type"`
	Id   int64           `json:"id"`
	Time int64           `json:"time"`
}

type MessageInfoType

type MessageInfoType string
const (
	MessageInfoTypeSource         MessageInfoType = "Source"
	MessageInfoTypeQuote          MessageInfoType = "Quote"
	MessageInfoTypeAt             MessageInfoType = "At"
	MessageInfoTypeAtAll          MessageInfoType = "AtAll"
	MessageInfoTypeFace           MessageInfoType = "Face"
	MessageInfoTypePlain          MessageInfoType = "Plain"
	MessageInfoTypeImage          MessageInfoType = "Image"
	MessageInfoTypeFlashImage     MessageInfoType = "FlashImage"
	MessageInfoTypeVoice          MessageInfoType = "Voice"
	MessageInfoTypeXml            MessageInfoType = "Xml"
	MessageInfoTypeJson           MessageInfoType = "Json"
	MessageInfoTypeApp            MessageInfoType = "App"
	MessageInfoTypePoke           MessageInfoType = "Poke"
	MessageInfoTypeDice           MessageInfoType = "Dice"
	MessageInfoTypeMarketFace     MessageInfoType = "MarketFace"
	MessageInfoTypeMusicShare     MessageInfoType = "MusicShare"
	MessageInfoTypeForwardMessage MessageInfoType = "ForwardMessage"
	MessageInfoTypeFile           MessageInfoType = "File"
	MessageInfoTypeMiraiCode      MessageInfoType = "MiraiCode"
)

type MessageType

type MessageType string
const (
	MessageTypeFriend   MessageType = "FriendMessage"
	MessageTypeGroup    MessageType = "GroupMessage"
	MessageTypeTemp     MessageType = "TempMessage"
	MessageTypeStranger MessageType = "StrangerMessage"
	MessageTypeOther    MessageType = "OtherClientMessage"

	MessageTypeFriendSync   MessageType = "FriendSyncMessage"
	MessageTypeGroupSync    MessageType = "GroupSyncMessage"
	MessageTypeTempSync     MessageType = "TempSyncMessage"
	MessageTypeStrangerSync MessageType = "StrangerSyncMessage"
)

type Messages

type Messages []Message

func (Messages) Empty

func (ms Messages) Empty() bool

func (Messages) Len

func (ms Messages) Len() int

type ProfileResp

type ProfileResp struct {
	BaseResp
	Nickname string `json:"nickname"`
	Email    string `json:"email"`
	Age      int64  `json:"age"`
	Level    int64  `json:"level"`
	Sign     string `json:"sign"`
	Sex      Sex    `json:"sex"`
}

type ReleaseReq

type ReleaseReq struct {
	BaseReq
	QQ int64 `json:"qq"`
}

type SendMessageReq

type SendMessageReq struct {
	BaseReq
	Target int64 `json:"target,omitempty"`
	QQ     int64 `json:"qq,omitempty"`
	Group  int64 `json:"group,omitempty"`
	Quote  int64 `json:"quote,omitempty"`

	MessageChain []MessageInfoInterface `json:"messageChain,omitempty"`
}

type SendMessageResp

type SendMessageResp struct {
	BaseResp
	MessageId int64 `json:"messageId"`
}

type SessionInfoData

type SessionInfoData struct {
	SessionKey string        `json:"sessionKey"`
	QQ         SessionInfoQQ `json:"qq"`
}

type SessionInfoQQ

type SessionInfoQQ struct {
	Id       int64  `json:"id"`
	Nickname string `json:"nickname"`
	Remark   string `json:"remark"`
}

type SessionInfoReq

type SessionInfoReq struct {
	BaseReq
}

type SessionInfoResp

type SessionInfoResp struct {
	BaseResp
	Data SessionInfoData `json:"data"`
}

type Sex

type Sex string

type VerifyReq

type VerifyReq struct {
	VerifyKey string `json:"verifyKey,omitempty"`
}

type VerifyResp

type VerifyResp struct {
	BaseResp
	Session string `json:"session"`
}

Directories

Path Synopsis
internal
query
Package query implements encoding of structs into URL query parameters.
Package query implements encoding of structs into URL query parameters.

Jump to

Keyboard shortcuts

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