onebot

package
v1.0.0-rc5 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2023 License: AGPL-3.0 Imports: 1 Imported by: 2

Documentation

Overview

Package onebot defines onebot protocol struct and some spec info.

Index

Constants

This section is empty.

Variables

View Source
var V11 = &Spec{
	Version:          11,
	SupportedActions: supportedV11,
}

V11 OneBot V11

View Source
var V12 = &Spec{
	Version:          12,
	SupportedActions: supportedV12,
}

V12 OneBot V12

Functions

This section is empty.

Types

type Event

type Event struct {
	ID         string
	Time       int64
	Type       string
	DetailType string
	SubType    string
	Self       *Self
}

Event 事件

https://12.onebot.dev/connect/data-protocol/event/

type Request

type Request struct {
	Action string // 动作名称
	Params any    // 动作参数
	Echo   any    // 每次请求的唯一标识
}

Request 动作请求是应用端为了主动向 OneBot 实现请求服务而发送的数据

https://12.onebot.dev/connect/data-protocol/action-request/

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 Self

type Self struct {
	Platform string `json:"platform"`
	UserID   string `json:"user_id"`
}

Self 机器人自身标识

https://12.onebot.dev/connect/data-protocol/basic-types/#_10

type Spec

type Spec struct {
	Version          int // must be 11 or 12
	SupportedActions []string
}

Spec OneBot Specification

func (*Spec) ConvertID

func (s *Spec) ConvertID(id any) any

ConvertID 根据版本转换ID

Jump to

Keyboard shortcuts

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