Documentation ¶
Index ¶
- Constants
- func EscapeCQString(s string) string
- func GetMsgData[T any](msg *Segment) *T
- func GetMsgDataUnsafe[T any](msg *Segment) *T
- func UnescapeCQString(s string) string
- type AnonymousData
- type AtData
- type BasicFileData
- type BasicIdData
- type BasicMusicData
- type CQMessage
- type CQStringer
- type Chain
- func (mc *Chain) AddAt(userId string)
- func (mc *Chain) AddAtAll()
- func (mc *Chain) AddAtUser(userId qq.UserId)
- func (mc *Chain) AddSegment(msg Segment)
- func (mc *Chain) AddSegments(msg ...Segment)
- func (mc *Chain) AddText(text string)
- func (mc *Chain) AppendChain(chain Chain)
- func (mc *Chain) At(idx int) Segment
- func (mc *Chain) AtRef(idx int) *Segment
- func (mc *Chain) Clear()
- func (mc *Chain) FirstImage() *ImageData
- func (mc *Chain) FirstOfType(msgType SegmentType) Segment
- func (mc *Chain) FirstOfTypeRef(msgType SegmentType) *Segment
- func (mc *Chain) FirstText() *TextData
- func (mc *Chain) GetSegmentsWithType(msgType SegmentType) []Segment
- func (mc *Chain) Len() int
- func (mc *Chain) MarshalJSON() ([]byte, error)
- func (mc *Chain) PrependChain(chain Chain)
- func (mc *Chain) PrependSegment(msg Segment)
- func (mc *Chain) SetReplyTo(msgId qq.MessageId)
- func (mc *Chain) SetSendAsAnonymous(ignore bool)
- func (mc *Chain) String() string
- func (mc *Chain) UnmarshalJSON(data []byte) error
- type ContactData
- type CustomMusicData
- type CustomNodeData
- type DiceData
- type FaceData
- type FileData
- type ForwardData
- type IdNodeData
- type ImageData
- type JsonData
- type LocationData
- type MusicData
- type MusicType
- type PokeData
- type RecordData
- type ReplyData
- type RpsData
- type Segment
- func NewAtMessage(qq string) Segment
- func NewDiceMessage() Segment
- func NewFaceSegment(id int64) Segment
- func NewImageSegment(file string) Segment
- func NewRecordSegment(file string) Segment
- func NewRpsMessage() Segment
- func NewShakeMessage() Segment
- func NewTextSegment(text string) Segment
- func NewVideoSegment(file string) Segment
- func (m Segment) AsChain() *Chain
- func (m Segment) GetAtData() *AtData
- func (m Segment) GetContactData() *ContactData
- func (m Segment) GetCustomNodeData() any
- func (m Segment) GetDataPtr() any
- func (m Segment) GetDiceData() *DiceData
- func (m Segment) GetFaceData() *FaceData
- func (m Segment) GetForwardData() *ForwardData
- func (m Segment) GetImageData() *ImageData
- func (m Segment) GetJsonData() *JsonData
- func (m Segment) GetLocationData() *LocationData
- func (m Segment) GetMusicData() *MusicData
- func (m Segment) GetPokeData() *PokeData
- func (m Segment) GetRecordData() *RecordData
- func (m Segment) GetReplyData() *ReplyData
- func (m Segment) GetRpsData() *RpsData
- func (m Segment) GetShakeData() *ShakeData
- func (m Segment) GetShareData() *ShareData
- func (m Segment) GetTextData() *TextData
- func (m Segment) GetType() SegmentType
- func (m Segment) GetVideoData() *VideoData
- func (m Segment) GetXmlData() *XmlData
- func (m Segment) IsInvalid() bool
- func (m Segment) String() string
- func (m *Segment) UnmarshalJSON(data []byte) error
- type SegmentType
- type SendableMessage
- type ShakeData
- type ShareData
- type TextData
- type UnknownData
- type VideoData
- type XmlData
Constants ¶
const ( SegmentTypeText SegmentType = "text" SegmentTypeFace SegmentType = "face" SegmentTypeImage SegmentType = "image" SegmentTypeRecord SegmentType = "record" SegmentTypeVideo SegmentType = "video" // MessageTypeVideo 短视频 SegmentTypeAt SegmentType = "at" // MessageTypeAt @某人 SegmentTypeRps SegmentType = "rps" // MessageTypeRps 猜拳魔法表情 SegmentTypeDice SegmentType = "dice" // MessageTypeDice 掷骰子魔法表情 SegmentTypeShake SegmentType = "shake" // MessageTypeShake 窗口抖动 SegmentTypePoke SegmentType = "poke" SegmentTypeAnonymous SegmentType = "anonymous" SegmentTypeContact SegmentType = "contact" SegmentTypeLocation SegmentType = "location" SegmentTypeMusic SegmentType = "music" SegmentTypeReply SegmentType = "reply" SegmentTypeForward SegmentType = "forward" SegmentTypeNode SegmentType = "node" SegmentTypeXml SegmentType = "xml" SegmentTypeJson SegmentType = "json" MusicTypeQQ MusicType = "qq" MusicType163 MusicType = "163" MusicTypeXm MusicType = "xm" MusicTypeCustom MusicType = "custom" ImageTypeFlash = "flash" )
Variables ¶
This section is empty.
Functions ¶
func EscapeCQString ¶
func GetMsgDataUnsafe ¶
GetMsgDataUnsafe 获取类型为 T 的消息数据,如果类型不匹配会引发 panic
func UnescapeCQString ¶
Types ¶
type AnonymousData ¶
type AnonymousData struct {
Ignore bool `json:"ignore,omitempty"`
}
func NewAnonymous ¶
func NewAnonymous(ignore bool) *AnonymousData
func (*AnonymousData) Segment ¶
func (d *AnonymousData) Segment() Segment
type BasicFileData ¶
type BasicIdData ¶
type BasicIdData struct {
Id int64 `json:"id,string"`
}
type BasicMusicData ¶
type BasicMusicData struct {
Type MusicType `json:"type"`
}
type CQMessage ¶
type CQMessage interface { // GetType 获取消息类型 GetType() SegmentType // String CQ 码的消息字符串 CQStringer }
CQMessage QQ 消息
type CQStringer ¶
type Chain ¶
type Chain struct {
Messages []Segment
}
func ParseCQString ¶
func (*Chain) AddSegment ¶
func (*Chain) AddSegments ¶
func (*Chain) AppendChain ¶
func (*Chain) FirstImage ¶
func (*Chain) FirstOfType ¶
func (mc *Chain) FirstOfType(msgType SegmentType) Segment
FirstOfType 返回第一个类型为 msgType 的消息的拷贝。如果没有找到,返回空消息。
func (*Chain) FirstOfTypeRef ¶
func (mc *Chain) FirstOfTypeRef(msgType SegmentType) *Segment
FirstOfTypeRef 返回第一个类型为 msgType 的消息的引用。如果没有找到,返回 nil。
func (*Chain) GetSegmentsWithType ¶
func (mc *Chain) GetSegmentsWithType(msgType SegmentType) []Segment
func (*Chain) MarshalJSON ¶
func (*Chain) PrependChain ¶
func (*Chain) PrependSegment ¶
func (*Chain) SetSendAsAnonymous ¶
SetSendAsAnonymous 设置是否匿名发送消息。当 ignore 为 true 时,将在无法匿名发送消息时继续发送消息。
func (*Chain) UnmarshalJSON ¶
type ContactData ¶
type ContactData struct { Type string `json:"type"` BasicIdData }
func NewContact ¶
func NewContact(t string, id int64) *ContactData
func (*ContactData) Segment ¶
func (d *ContactData) Segment() Segment
type CustomMusicData ¶
type CustomMusicData struct { BasicMusicData Title string `json:"title"` Url string `json:"url"` Audio string `json:"audio"` }
func NewCustomMusic ¶
func NewCustomMusic(title, url, audio string) *CustomMusicData
func (*CustomMusicData) Segment ¶
func (d *CustomMusicData) Segment() Segment
type CustomNodeData ¶
type CustomNodeData struct { UserId qq.UserId `json:"user_id,string"` Nickname string `json:"nickname"` Content any `json:"content"` }
func NewCustomNode ¶
func NewCustomNode[T SendableMessage](userId qq.UserId, nickname string, content T) *CustomNodeData
func (*CustomNodeData) Segment ¶
func (d *CustomNodeData) Segment() Segment
type FaceData ¶
type FaceData BasicIdData
type FileData ¶
type FileData struct { BasicFileData // Name 文件名【NapCat 扩展】 Name string `json:"name,omitempty"` }
type ForwardData ¶
type ForwardData BasicIdData
func (*ForwardData) Segment ¶
func (d *ForwardData) Segment() Segment
type IdNodeData ¶
type IdNodeData BasicIdData
func NewNode ¶
func NewNode(id int64) *IdNodeData
func (*IdNodeData) Segment ¶
func (d *IdNodeData) Segment() Segment
type ImageData ¶
type ImageData struct { BasicFileData // Summary 自定义显示的文件名【LLOneBot 扩展】 Summary string `json:"summary,omitempty"` Type string `json:"type,omitempty"` }
type LocationData ¶
type LocationData struct { Lat float64 `json:"lat,string"` Lon float64 `json:"lon,string"` Title string `json:"title,omitempty"` Content string `json:"content,omitempty"` }
func NewLocation ¶
func NewLocation(lat, lon float64) *LocationData
func (*LocationData) Segment ¶
func (d *LocationData) Segment() Segment
type MusicData ¶
type MusicData struct { BasicMusicData BasicIdData }
type PokeData ¶
type RecordData ¶
type RecordData struct { BasicFileData Magic int `json:"magic,omitempty"` }
func NewRecord ¶
func NewRecord(file string) *RecordData
func (*RecordData) Segment ¶
func (d *RecordData) Segment() Segment
type ReplyData ¶
type ReplyData BasicIdData
type Segment ¶
type Segment struct { Type SegmentType `json:"type"` Data any `json:"data"` }
Segment 消息片段
func NewAtMessage ¶
func NewDiceMessage ¶
func NewDiceMessage() Segment
func NewFaceSegment ¶
func NewImageSegment ¶
func NewRecordSegment ¶
func NewRpsMessage ¶
func NewRpsMessage() Segment
func NewShakeMessage ¶
func NewShakeMessage() Segment
func NewTextSegment ¶
func NewVideoSegment ¶
func (Segment) GetContactData ¶
func (m Segment) GetContactData() *ContactData
GetContactData 获取联系人消息数据,如果类型不匹配返回 nil
func (Segment) GetCustomNodeData ¶
GetCustomNodeData 获取自定义节点消息数据,如果类型不匹配返回 nil
func (Segment) GetDataPtr ¶
func (Segment) GetDiceData ¶
GetDiceData 获取掷骰子消息数据,如果类型不匹配返回 nil
func (Segment) GetFaceData ¶
GetFaceData 获取表情消息数据,如果类型不匹配返回 nil
func (Segment) GetForwardData ¶
func (m Segment) GetForwardData() *ForwardData
GetForwardData 获取转发消息数据,如果类型不匹配返回 nil
func (Segment) GetImageData ¶
GetImageData 获取图片消息数据,如果类型不匹配返回 nil
func (Segment) GetJsonData ¶
GetJsonData 获取 JSON 消息数据,如果类型不匹配返回 nil
func (Segment) GetLocationData ¶
func (m Segment) GetLocationData() *LocationData
GetLocationData 获取位置消息数据,如果类型不匹配返回 nil
func (Segment) GetMusicData ¶
GetMusicData 获取音乐消息数据,如果类型不匹配返回 nil
func (Segment) GetPokeData ¶
GetPokeData 获取戳一戳消息数据,如果类型不匹配返回 nil
func (Segment) GetRecordData ¶
func (m Segment) GetRecordData() *RecordData
GetRecordData 获取语音消息数据,如果类型不匹配返回 nil
func (Segment) GetReplyData ¶
GetReplyData 获取回复消息数据,如果类型不匹配返回 nil
func (Segment) GetRpsData ¶
GetRpsData 获取猜拳消息数据,如果类型不匹配返回 nil
func (Segment) GetShakeData ¶
GetShakeData 获取窗口抖动消息数据,如果类型不匹配返回 nil
func (Segment) GetShareData ¶
GetShareData 获取分享消息数据,如果类型不匹配返回 nil
func (Segment) GetTextData ¶
GetTextData 获取文本消息数据,如果类型不匹配返回 nil
func (Segment) GetType ¶
func (m Segment) GetType() SegmentType
func (Segment) GetVideoData ¶
GetVideoData 获取视频消息数据,如果类型不匹配返回 nil
func (Segment) GetXmlData ¶
GetXmlData 获取 XML 消息数据,如果类型不匹配返回 nil
func (*Segment) UnmarshalJSON ¶
type SendableMessage ¶
type UnknownData ¶
type VideoData ¶
type VideoData BasicFileData