onebot

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: GPL-3.0 Imports: 24 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DefaultConfigPath   = "conf/onebot/"
	CacheUpdateInterval = 5 * time.Minute // Cache refresh interval
)

Variables

This section is empty.

Functions

This section is empty.

Types

type APIResponse

type APIResponse struct {
	Status  string      `json:"status"`
	RetCode int         `json:"retcode"`
	Data    interface{} `json:"data"`
	Echo    interface{} `json:"echo"`
}

OneBot API response structures

type Anonymous

type Anonymous struct {
	ID   int64  `json:"id"`
	Name string `json:"name"`
	Flag string `json:"flag"`
}

type BaseEvent

type BaseEvent struct {
	Time     int64  `json:"time"`
	SelfID   int64  `json:"self_id"`
	PostType string `json:"post_type"`
}

OneBot event structures

type Cache

type Cache struct {
	// contains filtered or unexported fields
}

Cache structures

type Config

type Config struct {
	// connection mode: "http", "ws", "ws_reverse"
	Mode string `json:"mode"`

	// HTTP configuration
	HTTP *struct {
		Host        string `json:"host"`
		Port        int    `json:"port"`
		AccessToken string `json:"access_token"`
		PostURL     string `json:"post_url"`
		Secret      string `json:"secret"`
		Timeout     int    `json:"timeout,omitempty"` // seconds
	} `json:"http,omitempty"`

	// WebSocket configuration
	WebSocket *struct {
		Host        string `json:"host"`
		Port        int    `json:"port"`
		AccessToken string `json:"access_token,omitempty"`
	} `json:"ws,omitempty"`

	// Reverse WebSocket configuration
	ReverseWebSocket *struct {
		Host              string `json:"host"`
		Port              int    `json:"port"`
		AccessToken       string `json:"access_token,omitempty"`
		Path              string `json:"path,omitempty"`
		ReconnectInterval int    `json:"reconnect_interval,omitempty"` // milliseconds
	} `json:"ws_reverse,omitempty"`

	// Message format: "string" or "array"
	MessageFormat string `json:"message_format,omitempty"`

	// Whether to enable heartbeat
	Heartbeat *struct {
		Enable   bool `json:"enable"`
		Interval int  `json:"interval,omitempty"` // milliseconds
	} `json:"heartbeat,omitempty"`

	// API rate limiting
	RateLimit *struct {
		Enable   bool `json:"enable"`
		Interval int  `json:"interval"` // milliseconds
	} `json:"rate_limit,omitempty"`

	// Bot behavior settings
	IgnoreSelf    bool   `json:"ignore_self,omitempty"`
	Debug         bool   `json:"debug,omitempty"`
	CommandPrefix string `json:"command_prefix,omitempty"`
}

type Connection

type Connection interface {
}

type Context

type Context struct {
	// contains filtered or unexported fields
}

func (*Context) Contacts

func (ctx *Context) Contacts() []entity.User
func (ctx *Context) DownloadResourceFromRefLink(refLink string) (string, error)

func (*Context) GetGroupMemberInfo

func (ctx *Context) GetGroupMemberInfo(groupID, userID int64, noCache bool) (*GroupMember, error)

GetGroupMemberInfo retrieves detailed information about a specific group member

func (*Context) Groups

func (ctx *Context) Groups() []entity.Group

func (*Context) ID

func (ctx *Context) ID() string

func (*Context) InvalidateCache

func (ctx *Context) InvalidateCache()

InvalidateCache clears all cached data

func (*Context) InvalidateFriendCache

func (ctx *Context) InvalidateFriendCache()

InvalidateFriendCache clears only friend list cache

func (*Context) InvalidateGroupCache

func (ctx *Context) InvalidateGroupCache()

InvalidateGroupCache clears only group list cache

func (*Context) Name

func (ctx *Context) Name() string

func (*Context) NewMessageBuilder

func (ctx *Context) NewMessageBuilder() botc.MessageBuilder

func (*Context) Protocol

func (ctx *Context) Protocol() string

func (*Context) RefreshCache

func (ctx *Context) RefreshCache() error

RefreshCache forces a refresh of all cached data

func (*Context) SendDirectMessage

func (ctx *Context) SendDirectMessage(target entity.User, elements []*botc.MessageElement) (*botc.BaseMessage, error)

func (*Context) SendGroupMessage

func (ctx *Context) SendGroupMessage(target entity.Group, elements []*botc.MessageElement) (*botc.BaseMessage, error)

func (*Context) Status

func (ctx *Context) Status() botc.LoginStatus

type Friend

type Friend struct {
	UserID   int64  `json:"user_id"`
	Nickname string `json:"nickname"`
	Remark   string `json:"remark"`
}

type Group

type Group struct {
	GroupID        int64  `json:"group_id"`
	GroupName      string `json:"group_name"`
	MemberCount    int32  `json:"member_count"`
	MaxMemberCount int32  `json:"max_member_count"`
}

type GroupMember

type GroupMember struct {
	GroupID         int64  `json:"group_id"`
	UserID          int64  `json:"user_id"`
	Nickname        string `json:"nickname"`
	Card            string `json:"card"`
	Sex             string `json:"sex"`
	Age             int32  `json:"age"`
	Area            string `json:"area"`
	JoinTime        int32  `json:"join_time"`
	LastSentTime    int32  `json:"last_sent_time"`
	Level           string `json:"level"`
	Role            string `json:"role"`
	Unfriendly      bool   `json:"unfriendly"`
	Title           string `json:"title"`
	TitleExpireTime int32  `json:"title_expire_time"`
	CardChangeable  bool   `json:"card_changeable"`
}

type LoginInfo

type LoginInfo struct {
	UserID   int64  `json:"user_id"`
	Nickname string `json:"nickname"`
}

type MessageBuilder

type MessageBuilder struct {
	// contains filtered or unexported fields
}

func (*MessageBuilder) At

func (mb *MessageBuilder) At(target string) botc.MessageBuilder

func (*MessageBuilder) Elements

func (mb *MessageBuilder) Elements() []*botc.MessageElement

func (*MessageBuilder) Face

func (*MessageBuilder) File

func (mb *MessageBuilder) File(url string) botc.MessageBuilder

func (*MessageBuilder) ImageFromData

func (mb *MessageBuilder) ImageFromData(data []byte) botc.MessageBuilder

func (*MessageBuilder) ImageFromFile

func (mb *MessageBuilder) ImageFromFile(path string) botc.MessageBuilder

func (*MessageBuilder) ImageFromUrl

func (mb *MessageBuilder) ImageFromUrl(url string) botc.MessageBuilder

func (*MessageBuilder) Mention

func (mb *MessageBuilder) Mention(id string) botc.MessageBuilder

func (*MessageBuilder) Protocol

func (mb *MessageBuilder) Protocol() string

func (*MessageBuilder) Quote

func (*MessageBuilder) Reply

func (mb *MessageBuilder) Reply(messageID string) botc.MessageBuilder

func (*MessageBuilder) ReplyTo

func (mb *MessageBuilder) ReplyTo(ctx botc.MessageContext) (*botc.BaseMessage, error)

func (*MessageBuilder) Send

func (mb *MessageBuilder) Send(id string) (*botc.BaseMessage, error)

func (*MessageBuilder) Text

func (mb *MessageBuilder) Text(text string) botc.MessageBuilder

func (*MessageBuilder) Video

func (mb *MessageBuilder) Video(url string) botc.MessageBuilder

func (*MessageBuilder) Voice

func (mb *MessageBuilder) Voice(url string) botc.MessageBuilder

type MessageContext

type MessageContext struct {
	// contains filtered or unexported fields
}

Message context for OneBot

func (*MessageContext) BotContext

func (mc *MessageContext) BotContext() botc.BotContext

func (*MessageContext) Message

func (mc *MessageContext) Message() *botc.BaseMessage

func (*MessageContext) NewMessageBuilder

func (mc *MessageContext) NewMessageBuilder() botc.MessageBuilder

func (*MessageContext) Protocol

func (mc *MessageContext) Protocol() string

func (*MessageContext) Reply

func (mc *MessageContext) Reply(elements []*botc.MessageElement) (*botc.BaseMessage, error)

func (*MessageContext) ReplyText

func (mc *MessageContext) ReplyText(a ...any) (*botc.BaseMessage, error)

func (*MessageContext) SenderID

func (mc *MessageContext) SenderID() string

func (*MessageContext) String

func (mc *MessageContext) String() string

type MessageEvent

type MessageEvent struct {
	BaseEvent
	MessageType string          `json:"message_type"`
	SubType     string          `json:"sub_type"`
	MessageID   int64           `json:"message_id"`
	UserID      int64           `json:"user_id"`
	GroupID     int64           `json:"group_id,omitempty"`
	Message     json.RawMessage `json:"message"`
	RawMessage  string          `json:"raw_message"`
	Font        int32           `json:"font"`
	Sender      Sender          `json:"sender"`
	Anonymous   *Anonymous      `json:"anonymous,omitempty"`
}

type MetaEvent

type MetaEvent struct {
	BaseEvent
	MetaEventType string      `json:"meta_event_type"`
	SubType       string      `json:"sub_type,omitempty"`
	Status        interface{} `json:"status,omitempty"`
	Interval      int64       `json:"interval,omitempty"`
}

type NoticeEvent

type NoticeEvent struct {
	BaseEvent
	NoticeType string `json:"notice_type"`
	SubType    string `json:"sub_type,omitempty"`
	GroupID    int64  `json:"group_id,omitempty"`
	UserID     int64  `json:"user_id,omitempty"`
	OperatorID int64  `json:"operator_id,omitempty"`
	TargetID   int64  `json:"target_id,omitempty"`
	Duration   int64  `json:"duration,omitempty"`
	MessageID  int64  `json:"message_id,omitempty"`
	File       *struct {
		ID    string `json:"id"`
		Name  string `json:"name"`
		Size  int64  `json:"size"`
		BusID int64  `json:"busid"`
	} `json:"file,omitempty"`
}

type RequestEvent

type RequestEvent struct {
	BaseEvent
	RequestType string `json:"request_type"`
	SubType     string `json:"sub_type,omitempty"`
	UserID      int64  `json:"user_id"`
	GroupID     int64  `json:"group_id,omitempty"`
	Comment     string `json:"comment"`
	Flag        string `json:"flag"`
}

type SendMessageResponse

type SendMessageResponse struct {
	MessageID int64 `json:"message_id"`
}

type Sender

type Sender struct {
	UserID   int64  `json:"user_id"`
	Nickname string `json:"nickname"`
	Card     string `json:"card,omitempty"`
	Sex      string `json:"sex"`
	Age      int32  `json:"age"`
	Area     string `json:"area,omitempty"`
	Level    string `json:"level,omitempty"`
	Role     string `json:"role,omitempty"`
	Title    string `json:"title,omitempty"`
}

type Service

type Service struct {
	// contains filtered or unexported fields
}

func Create

func Create() *Service
func (s *Service) DownloadResourceFromRefLink(refLink string) (string, error)

func (*Service) Init

func (s *Service) Init(grb *GoroBot.Instant) error

func (*Service) Name

func (s *Service) Name() string

func (*Service) Protocol

func (s *Service) Protocol() string

func (*Service) Release

func (s *Service) Release(grb *GoroBot.Instant) error

type Status

type Status struct {
	Online bool `json:"online"`
	Good   bool `json:"good"`
}

Jump to

Keyboard shortcuts

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