Documentation
¶
Index ¶
- Constants
- func AddReceivedCount()
- func AddSentCount()
- func GetReceivedCount() (result int)
- func GetSentCount() (result int)
- type ActionCall
- type ActionChannel
- type FileType
- type ImageType
- type Message
- func (m *Message) Any(data MessageType) *Message
- func (m *Message) AttachSegment(seg MessageSegment)
- func (m *Message) File(file string) *Message
- func (m Message) GetRawText() string
- func (m Message) GetSegments() []MessageSegment
- func (m *Message) Image(file string) *Message
- func (m *Message) Join(msg Message) *Message
- func (m *Message) MarshalJSON() ([]byte, error)
- func (m *Message) Text(text string) *Message
- func (m *Message) UnmarshalJSON(data []byte) error
- func (m *Message) Video(file string) *Message
- func (m *Message) Voice(file string) *Message
- type MessageChannel
- type MessageSegment
- type MessageType
- type TextType
- type VideoType
- type VoiceType
Constants ¶
View Source
const ACTION_CHAN_CAPACITY = 64
View Source
const LOG_MESSAGE_LEN_THRESHOLD = 256
View Source
const MESSAGE_CHAN_CAPACITY = 64
Variables ¶
This section is empty.
Functions ¶
func AddReceivedCount ¶
func AddReceivedCount()
AddReceivedCount increases the received count by one
func GetReceivedCount ¶
func GetReceivedCount() (result int)
GetReceivedCount returns the current received count
Types ¶
type ActionCall ¶
type ActionCall struct {
// Which action
Action any
// Which adapter to call
AdapterName string
// Which channel to push the result, will initialize automatically
ResultChannel *chan any
}
If you want to call adapter action, you should use this struct
type ActionChannel ¶
type ActionChannel struct {
// contains filtered or unexported fields
}
func (*ActionChannel) Pull ¶
func (ac *ActionChannel) Pull() *ActionCall
Pull a message from the channel
func (*ActionChannel) Push ¶
func (ac *ActionChannel) Push(action *ActionCall)
Push a message to the channel
If the channel is full, the oldest message will be dropped ¶
type FileType ¶
type FileType struct {
File string `json:"file"`
}
func (FileType) AdapterName ¶ added in v1.0.1
func (FileType) ToRawText ¶
func (serializer FileType) ToRawText(msg MessageSegment) string
type ImageType ¶
type ImageType struct {
File string `json:"file"`
}
func (ImageType) AdapterName ¶ added in v1.0.1
func (ImageType) ToRawText ¶
func (serializer ImageType) ToRawText(msg MessageSegment) string
type Message ¶
type Message struct {
// Is the message to me?
IsToMe bool
// Which group is it in?(Only useful with group message and notice)
Group string
// Who is sending this message?
Sender string
// Who is receiving this message?
Receiver string
// Who am i?
Self string
// contains filtered or unexported fields
}
This describes the whole message
func NewMessage ¶ added in v1.1.0
func NewMessage() *Message
func (*Message) Any ¶ added in v1.1.0
func (m *Message) Any(data MessageType) *Message
AnySegment attachs any message segment to message
func (*Message) AttachSegment ¶ added in v1.0.1
func (m *Message) AttachSegment(seg MessageSegment)
Attach a segment for a message
func (Message) GetRawText ¶
func (Message) GetSegments ¶
func (m Message) GetSegments() []MessageSegment
func (*Message) MarshalJSON ¶
func (*Message) UnmarshalJSON ¶
type MessageChannel ¶
type MessageChannel struct {
// contains filtered or unexported fields
}
func (*MessageChannel) Pull ¶
func (mc *MessageChannel) Pull() Message
Pull a message from the channel
type MessageSegment ¶
type MessageSegment struct {
// Message type
Type string `json:"type"`
// Make sure it implements MessageType interface
Data MessageType `json:"data"`
}
This describes a simple part of a message
type MessageType ¶
type MessageType interface {
// Which adapter is this message for
AdapterName() string
// Which message type is this message for
TypeName() string
// Convert this message segment to raw text
ToRawText(msg MessageSegment) string
}
Implement this to create a message type
func ToBuiltIn ¶ added in v1.1.0
func ToBuiltIn(typeName string, msg any) MessageType
Convert raw MessageSegment.Data to built-in MessageType
type TextType ¶
type TextType struct {
Text string `json:"text"`
}
func (TextType) AdapterName ¶ added in v1.0.1
func (TextType) ToRawText ¶
func (serializer TextType) ToRawText(msg MessageSegment) string
type VideoType ¶
type VideoType struct {
File string `json:"file"`
}
func (VideoType) AdapterName ¶ added in v1.0.1
func (VideoType) ToRawText ¶
func (serializer VideoType) ToRawText(msg MessageSegment) string
type VoiceType ¶
type VoiceType struct {
File string `json:"file"`
}
func (VoiceType) AdapterName ¶ added in v1.0.1
func (VoiceType) ToRawText ¶
func (serializer VoiceType) ToRawText(msg MessageSegment) string
Click to show internal directories.
Click to hide internal directories.