msg

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2023 License: AGPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package msg 提供了go-cqhttp消息中间表示,CQ码处理等等

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EscapeText

func EscapeText(s string) string

EscapeText 将字符串raw中部分字符转义

  • & -> &
  • [ -> [
  • ] -> ]

func EscapeValue

func EscapeValue(value string) string

EscapeValue 将字符串value中部分字符转义

  • , -> ,
  • & -> &
  • [ -> [
  • ] -> ]

func QuoteJSON

func QuoteJSON(s string) string

QuoteJSON 按JSON转义为字符加上双引号

func UnescapeText

func UnescapeText(content string) string

UnescapeText 将字符串content中部分字符反转义

  • & -> &
  • [ -> [
  • ] -> ]

func UnescapeValue

func UnescapeValue(content string) string

UnescapeValue 将字符串content中部分字符反转义

  • , -> ,
  • & -> &
  • [ -> [
  • ] -> ]

Types

type Element

type Element struct {
	Type string
	Data []Pair
}

Element single message

func ParseObject

func ParseObject(m gjson.Result) (r []Element)

ParseObject 将消息JSON对象转为消息元素数组

func ParseString

func ParseString(raw string) (r []Element)

ParseString 将字符串(CQ码)转为消息元素数组

func (*Element) CQCode

func (e *Element) CQCode() string

CQCode convert element to cqcode

func (*Element) Get

func (e *Element) Get(k string) string

Get 获取指定值

func (*Element) MarshalJSON

func (e *Element) MarshalJSON() ([]byte, error)

MarshalJSON see encoding/json.Marshaler

func (*Element) WriteCQCodeTo

func (e *Element) WriteCQCodeTo(sb *strings.Builder)

WriteCQCodeTo write element's cqcode into sb

type LocalImage

type LocalImage struct {
	Stream io.ReadSeeker
	File   string
	URL    string

	Flash    bool
	EffectID int32
}

LocalImage 本地图片

func (*LocalImage) Type

func (e *LocalImage) Type() message.ElementType

Type implements the message.IMessageElement.

type LocalVideo

type LocalVideo struct {
	File  string
	Thumb io.ReadSeeker
}

LocalVideo 本地视频

func (*LocalVideo) Type

func (e *LocalVideo) Type() message.ElementType

Type impl message.IMessageElement

type Pair

type Pair struct {
	K string
	V string
}

Pair key value pair

type Poke

type Poke struct {
	Target int64
}

Poke 拍一拍

func (*Poke) Type

func (e *Poke) Type() message.ElementType

Type 获取元素类型ID

Jump to

Keyboard shortcuts

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