Documentation
¶
Overview ¶
Package onebot defines onebot protocol struct and some spec info.
Index ¶
- Variables
- type Attr
- func Any(key string, value any) Attr
- func Bool(key string, v bool) Attr
- func Duration(key string, v time.Duration) Attr
- func Float64(key string, v float64) Attr
- func Group(key string, as ...Attr) Attr
- func Int(key string, value int) Attr
- func Int64(key string, value int64) Attr
- func String(key, value string) Attr
- func Time(key string, v time.Time) Attr
- func Uint64(key string, v uint64) Attr
- type Event
- type Kind
- type Request
- type Response
- type Self
- type Spec
- type Value
- func AnyValue(v any) Value
- func BoolValue(v bool) Value
- func DurationValue(v time.Duration) Value
- func Float64Value(v float64) Value
- func GroupValue(as ...Attr) Value
- func Int64Value(v int64) Value
- func IntValue(v int) Value
- func StringValue(value string) Value
- func TimeValue(v time.Time) Value
- func Uint64Value(v uint64) Value
- func (v Value) Any() any
- func (v Value) Bool() bool
- func (v Value) Duration() time.Duration
- func (v Value) Float64() float64
- func (v Value) Group() []Attr
- func (v Value) Int64() int64
- func (v Value) Kind() Kind
- func (v Value) String() string
- func (v Value) Time() time.Time
- func (v Value) Uint64() uint64
Constants ¶
This section is empty.
Variables ¶
var V11 = &Spec{
Version: 11,
SupportedActions: supportedV11,
}
V11 OneBot V11
var V12 = &Spec{
Version: 12,
SupportedActions: supportedV12,
}
V12 OneBot V12
Functions ¶
This section is empty.
Types ¶
type Attr ¶
An Attr is a key-value pair.
func Any ¶
Any returns an Attr for the supplied value. See [Value.AnyValue] for how values are treated.
func Group ¶
Group returns an Attr for a Group Value. The caller must not subsequently mutate the argument slice.
Use Group to collect several Attrs under a single key on a log line, or as the result of LogValue in order to log a single value as multiple Attrs.
type Kind ¶
type Kind int
Kind is the kind of Value.
type Response ¶
type Response struct { Status string `json:"status"` // 执行状态,必须是 ok、failed 中的一个 Code int64 `json:"retcode"` // 返回码 Data any `json:"data"` // 响应数据 Message string `json:"message"` // 错误信息 Echo any `json:"echo"` // 动作请求中的 echo 字段值 }
Response 动作响应是 OneBot 实现收到应用端的动作请求并处理完毕后,发回应用端的数据
https://12.onebot.dev/connect/data-protocol/action-response/
type Value ¶
type Value struct {
// contains filtered or unexported fields
}
A Value can represent any Go value, but unlike type any, it can represent most small values without an allocation. The zero Value corresponds to nil.
func AnyValue ¶
AnyValue returns a Value for the supplied value.
If the supplied value is of type Value, it is returned unmodified.
Given a value of one of Go's predeclared string, bool, or (non-complex) numeric types, AnyValue returns a Value of kind String, Bool, Uint64, Int64, or Float64. The width of the original numeric type is not preserved.
Given a time.Time or time.Duration value, AnyValue returns a Value of kind KindTime or KindDuration. The monotonic time is not preserved.
For nil, or values of all other types, including named types whose underlying type is numeric, AnyValue returns a value of kind KindAny.
func DurationValue ¶
DurationValue returns a Value for a time.Duration.
func Float64Value ¶
Float64Value returns a Value for a floating-point number.
func GroupValue ¶
GroupValue returns a new Value for a list of Attrs. The caller must not subsequently mutate the argument slice.
func StringValue ¶
StringValue returns a new Value for a string.
func (Value) Duration ¶
Duration returns v's value as a time.Duration. It panics if v is not a time.Duration.
func (Value) String ¶
String returns Value's value as a string, formatted like fmt.Sprint. Unlike the methods Int64, Float64, and so on, which panic if v is of the wrong kind, String never panics.