miraiapi

package module
v0.0.0-...-af884a3 Latest Latest
Warning

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

Go to latest
Published: Aug 28, 2021 License: MIT Imports: 5 Imported by: 0

README

Documentation

Index

Constants

View Source
const (
	TypeTempMessage        = "TempMessage"
	TypeGroupMessage       = "GroupMessage"
	TypeFriendMessage      = "FriendMessage"
	TypeStrangerMessage    = "StrangerMessage"
	TypeOtherClientMessage = "OtherClientMessage"
)

消息来源类型

View Source
const (
	TypeAt         = "At"
	TypeApp        = "App"
	TypeXml        = "Xml"
	TypeJson       = "Json"
	TypeFace       = "Face"
	TypePoke       = "Poke"
	TypeText       = "Plain"
	TypeImage      = "Image"
	TypeVoice      = "Voice"
	TypeSource     = "Source"
	TypeMiraiCode  = "MiraiCode"
	TypeFlashImage = "FlashImage"
)

消息内容类型

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthRequest

type AuthRequest struct {
	Secret string `json:"verifyKey"`
}

type AuthResponse

type AuthResponse struct {
	Code   int64  `json:"code,omitempty"`
	Secret string `json:"session,omitempty"`
}

type BindRequest

type BindRequest struct {
	Secret string `json:"sessionKey,omitempty"`
	Number int64  `json:"qq,omitempty"`
}

type BindResponse

type BindResponse struct {
	Code    int64  `json:"code,omitempty"`
	Message string `json:"msg,omitempty"`
}

type Bot

type Bot struct {
	URL    string
	Secret string
	Number int64

	Interval time.Duration

	SessionToken         string
	PrefixesHandler      map[string][]EventHandler
	SuffixesHandler      map[string][]EventHandler
	GroupMessageHandler  []EventHandler
	FriendMessageHandler []EventHandler
}

func NewBot

func NewBot(api string, secret string, number int64) *Bot

func (*Bot) AddFriendMessageHandler

func (b *Bot) AddFriendMessageHandler(info EventHandler)

func (*Bot) AddGroupMessageHandler

func (b *Bot) AddGroupMessageHandler(info EventHandler)

func (*Bot) AddPrefixHandler

func (b *Bot) AddPrefixHandler(name string, info EventHandler)

func (*Bot) AddSuffixHandler

func (b *Bot) AddSuffixHandler(name string, info EventHandler)

func (*Bot) Auth

func (b *Bot) Auth() error

func (*Bot) Bind

func (b *Bot) Bind() error

func (*Bot) CountMessage

func (b *Bot) CountMessage() (int64, error)

func (*Bot) FetchMessage

func (b *Bot) FetchMessage() (MessageList, error)

func (*Bot) Release

func (b *Bot) Release() error

func (*Bot) Run

func (b *Bot) Run()

func (*Bot) RunOnce

func (b *Bot) RunOnce() error

func (*Bot) SendFriendMessage

func (b *Bot) SendFriendMessage(quote, target int64, list MessageDataList) error

func (*Bot) SendGroupMessage

func (b *Bot) SendGroupMessage(quote, target int64, list MessageDataList) error

type CountMessageResponse

type CountMessageResponse struct {
	Code    int64  `json:"code,omitempty"`
	Data    int64  `json:"data,omitempty"`
	Message string `json:"msg,omitempty"`
}

type EventHandler

type EventHandler func(b *Bot, m *Message)

type FetchLatestMessageResponse

type FetchLatestMessageResponse FetchMessageResponse

type FetchMessageResponse

type FetchMessageResponse struct {
	Code    int64       `json:"code,omitempty"`
	Data    MessageList `json:"data,omitempty"`
	Message string      `json:"msg,omitempty"`
}

type Message

type Message struct {
	Type   string          `json:"type,omitempty"`
	List   MessageDataList `json:"messageChain,omitempty"`
	Sender MessageSender   `json:"sender,omitempty"`
}

func (*Message) QuoteResponse

func (m *Message) QuoteResponse(b *Bot, list MessageDataList) error

func (*Message) Response

func (m *Message) Response(b *Bot, list MessageDataList) error

type MessageData

type MessageData struct {
	Type string `json:"type,omitempty"`

	// 来源(Source)
	SourceID   int64 `json:"id,omitempty"`
	SourceTime int64 `json:"time,omitempty"`

	// 引用(Quote)
	QuoteGroupID       int64          `json:"groupId,omitempty"`
	QuoteSenderID      int64          `json:"senderId,omitempty"`
	QuoteTargetID      int64          `json:"targetId,omitempty"`
	QuoteOriginMessage []*MessageData `json:"origin,omitempty"`

	// 艾特(At)
	AtTarget int64  `json:"target,omitempty"`
	AtString string `json:"display,omitempty"`

	// 表情(Face)
	FaceID int64 `json:"faceId,omitempty"`

	// 表情(Face) / 戳一戳(Poke)
	Name string `json:"name,omitempty"`

	// 文本(Plain)
	Text string `json:"text,omitempty"`

	// 图片(Image) / 闪照(FlashImage)
	ImageID string `json:"imageId,omitempty"`

	// 语音(Voice)
	VoiceID string `json:"voiceId,omitempty"`

	// 图片(Image) / 闪照(FlashImage) / 语音(Voice)
	URL    string `json:"url,omitempty"`
	Path   string `json:"path,omitempty"`
	Base64 string `json:"base64,omitempty"`

	// XML(Xml)
	XML string `json:"xml,omitempty"`

	// JSON(Json)
	Json string `json:"json,omitempty"`

	// APP(App)
	AppContent string `json:"content,omitempty"`

	// Mirai Code
	Code string `json:"code,omitempty"`
}

func (*MessageData) ToString

func (m *MessageData) ToString() string

type MessageDataList

type MessageDataList []*MessageData

func (*MessageDataList) ToString

func (m *MessageDataList) ToString() string

type MessageList

type MessageList []*Message

type MessageSender

type MessageSender struct {
	ID int64 `json:"id,omitempty"`

	// FriendMessage & StrangerMessage
	FriendRemark   string `json:"remark,omitempty"`
	FriendNickName string `json:"nickname,omitempty"`

	// GroupMessage & TempMessage
	GroupMemberName   string             `json:"memberName,omitempty"`
	GroupSpecialName  string             `json:"specialTitle,omitempty"`
	GroupPermission   string             `json:"permission,omitempty"`
	GroupJoinAt       int64              `json:"joinTimestamp,omitempty"`
	GroupLastSpeakAt  int64              `json:"lastSpeakTimestamp,omitempty"`
	GroupMuteTimeLeft int64              `json:"muteTimeRemaining,omitempty"`
	Group             MessageSenderGroup `json:"group,omitempty"`

	// OtherClientMessage
	OtherPlatform string `json:"platform,omitempty"`
}

type MessageSenderGroup

type MessageSenderGroup struct {
	ID         int64  `json:"id,omitempty"`
	Name       string `json:"name,omitempty"`
	Permission string `json:"permission,omitempty"`
}

type PeekLatestMessageResponse

type PeekLatestMessageResponse FetchMessageResponse

type PeekMessageResponse

type PeekMessageResponse FetchMessageResponse

type ReleaseRequest

type ReleaseRequest BindRequest

type ReleaseResponse

type ReleaseResponse BindResponse

type SendFriendMessageRequest

type SendFriendMessageRequest SendGroupMessageRequest

type SendFriendMessageResponse

type SendFriendMessageResponse SendGroupMessageResponse

type SendGroupMessageRequest

type SendGroupMessageRequest struct {
	List   MessageDataList `json:"messageChain,omitempty"`
	Quote  int64           `json:"quote,omitempty"`
	Target int64           `json:"target,omitempty"`
}

type SendGroupMessageResponse

type SendGroupMessageResponse struct {
	ID      int64  `json:"messageId,omitempty"`
	Code    int64  `json:"code,omitempty"`
	Message string `json:"msg,omitempty"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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