satori

package module
v0.0.0-...-5795eda Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2023 License: GPL-3.0 Imports: 12 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

README

satori-go

satori protocol in golang

Usage

client := NewClient("12345678", "i am token")

client.Listen(func(event *Event) {
	fmt.Println(event)
})

client.CreateMessage("87654321", "hello world!")

Thanks

  • chronocat - 神秘猫猫
  • zerobot - 一个基于onebot协议的机器人Go开发框架

Documentation

Index

Constants

View Source
const (
	// ChannelTypeText 文本频道.
	ChannelTypeText = iota

	// ChannelTypeVoice 语音频道.
	ChannelTypeVoice

	// ChannelTypeCategory 分类频道.
	ChannelTypeCategory

	// ChannelTypeDirect 私聊频道.
	ChannelTypeDirect
)
View Source
const (
	// LoginStatusOffline 离线.
	LoginStatusOffline = iota
	// LoginStatusOnline 在线.
	LoginStatusOnline
	// LoginStatusConnect 连接中.
	LoginStatusConnect
	// LoginStatusDisconnect 断开连接.
	LoginStatusDisconnect
	// LoginStatusReconnect 重新连接.
	LoginStatusReconnect
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Channel

type Channel struct {
	// ID 频道 ID
	ID string `json:"id"`

	// Type 频道类型
	Type ChannelType `json:"type"`

	// Name 频道名称
	Name string `json:"name"`

	// ParentID 父频道 ID
	ParentID string `json:"parent_id"`

	// Avatar 频道头像
	Avatar string `json:"avatar"`
}

Channel 频道.

type ChannelType

type ChannelType = int64

ChannelType 频道类型.

type Client

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

Client satori 客户端.

func NewClient

func NewClient(api, token string) *Client

NewClient 创建一个 satori 客户端.

func (*Client) ApproveFriend

func (cli *Client) ApproveFriend(messageID string, approve bool, comment string) (err error)

func (*Client) ApproveGuild

func (cli *Client) ApproveGuild(messageID string, approve bool, comment string) (err error)

func (*Client) ApproveGuildMember

func (cli *Client) ApproveGuildMember(messageID string, approve bool, comment string) (err error)

func (*Client) ClearReaction

func (cli *Client) ClearReaction(channelID, messageID, emoji string) (err error)

func (*Client) CreateChannel

func (cli *Client) CreateChannel(guildID string, data *Channel) (channel *Channel, err error)

func (*Client) CreateGuildRole

func (cli *Client) CreateGuildRole(guildID string, role *GuildRole) (role2 *GuildRole, err error)

func (*Client) CreateMessage

func (cli *Client) CreateMessage(channelID, content string) (messages []Message, err error)

func (*Client) CreateReaction

func (cli *Client) CreateReaction(channelID, messageID, emoji string) (err error)

func (*Client) CreateUserChannel

func (cli *Client) CreateUserChannel(userID string) (channel *Channel, err error)

func (*Client) DeleteChannel

func (cli *Client) DeleteChannel(channelID string) (err error)

func (*Client) DeleteGuildRole

func (cli *Client) DeleteGuildRole(guildID, roleID string) (err error)

func (*Client) DeleteMessage

func (cli *Client) DeleteMessage(channelID, messageID string) (err error)

func (*Client) DeleteReaction

func (cli *Client) DeleteReaction(channelID, messageID, emoji, userID string) (err error)

func (*Client) GetChannel

func (cli *Client) GetChannel(channelID string) (channel *Channel, err error)

func (*Client) GetGuild

func (cli *Client) GetGuild(guildID string) (guild *Guild, err error)

func (*Client) GetGuildMember

func (cli *Client) GetGuildMember(guildID, userID string) (member *GuildMember, err error)

func (*Client) GetLogin

func (cli *Client) GetLogin() (login *Login, err error)

func (*Client) GetMessage

func (cli *Client) GetMessage(channelID, messageID string) (message *Message, err error)

func (*Client) GetUser

func (cli *Client) GetUser(userID string) (user *User, err error)

func (*Client) KickGuildMember

func (cli *Client) KickGuildMember(guildID, userID string, permanent bool) (err error)

func (*Client) ListChannel

func (cli *Client) ListChannel(guildID, next string) (channels *List[Channel], err error)

func (*Client) ListFriend

func (cli *Client) ListFriend(next string) (users *List[User], err error)

func (*Client) ListGuild

func (cli *Client) ListGuild(next string) (guilds *List[Guild], err error)

func (*Client) ListGuildMember

func (cli *Client) ListGuildMember(guildID, next string) (members *List[GuildMember], err error)

func (*Client) ListGuildRole

func (cli *Client) ListGuildRole(guildID, next string) (roles *List[GuildRole], err error)

func (*Client) ListMessage

func (cli *Client) ListMessage(channelID, next string) (messages *List[Message], err error)

func (*Client) ListReaction

func (cli *Client) ListReaction(channelID, messageID, emoji, next string) (users *List[User], err error)

func (*Client) Listen

func (cli *Client) Listen(handler func(*Event))

Listen 监听 satori 事件.

func (*Client) Platform

func (cli *Client) Platform() string

Platform 获取当前 satori platform.

func (*Client) SelfID

func (cli *Client) SelfID() string

SelfID 获取当前 satori self_id.

func (*Client) SetGuildMemberRole

func (cli *Client) SetGuildMemberRole(guildID, userID, roleID string) (err error)

func (*Client) UnsetGuildMemberRole

func (cli *Client) UnsetGuildMemberRole(guildID, userID, roleID string) (err error)

func (*Client) UpdateChannel

func (cli *Client) UpdateChannel(channelID string, data *Channel) (err error)

func (*Client) UpdateGuildRole

func (cli *Client) UpdateGuildRole(guildID, roleID string, role *GuildRole) (err error)

func (*Client) UpdateMessage

func (cli *Client) UpdateMessage(channelID, messageID, content string) (err error)

type Event

type Event struct {
	// ID 事件 ID
	ID int64 `json:"id"`

	// Type 事件类型
	Type string `json:"type"`

	// Platform 接收者的平台名称
	Platform string `json:"platform"`

	// SelfID 接收者的平台账号
	SelfID string `json:"self_id"`

	// Timestamp 事件的时间戳
	Timestamp int64 `json:"timestamp"`

	// Channel 事件所属的频道
	Channel *Channel `json:"channel"`

	// Guild 事件所属的群组
	Guild *Guild `json:"guild"`

	// Login 事件的登录信息
	Login *Login `json:"login"`

	// Member 事件的目标成员
	Member *GuildMember `json:"member"`

	// Message 事件的消息
	Message *Message `json:"message"`

	// Operator 事件的操作者
	Operator *User `json:"operator"`

	// Role 事件的目标角色
	Role *GuildRole `json:"role"`

	// User 事件的目标用户
	User *User `json:"user"`
}

Event defines model for Event.

type Guild

type Guild struct {
	// ID 群组 ID
	ID string `json:"id"`

	// Name 群组名称
	Name string `json:"name"`

	// Avatar 群组头像
	Avatar string `json:"avatar"`
}

Guild 群组.

type GuildMember

type GuildMember struct {
	// 用户对象
	User *User `json:"user"`

	// Name 用户在群组中的名称
	Name string `json:"name"`

	// Avatar 用户在群组中的头像
	Avatar string `json:"avatar"`

	// JoinAt 加入时间
	JoinAt int64 `json:"joined_at"`
}

GuildMember 群组成员.

type GuildRole

type GuildRole struct {
	// ID 群组 ID
	ID string `json:"id"`

	// Name 群组名称
	Name string `json:"name"`
}

GuildRole 群组角色.

type Identify

type Identify struct {
	Token string `json:"token"`
}

type List

type List[T Channel | Guild | GuildMember | GuildRole | Message | User] struct {
	// Data 数据数组
	Data []T `json:"data"`

	// Next 分页
	Next string `json:"next"`
}

List defines model for List.

type Login

type Login struct {
	// User 用户对象
	User *User `json:"user"`

	// SelfID 平台账号
	SelfID string `json:"self_id"`

	// Platform 平台名称
	Platform string `json:"platform"`

	// Status 登录状态
	Status LoginStatus `json:"status"`
}

Login 登录信息.

type LoginStatus

type LoginStatus int64

LoginStatus 登录状态.

type Message

type Message struct {
	// ID 消息 ID
	ID string `json:"id"`

	// Content 消息内容
	Content string `json:"content"`

	// Channel 频道对象
	Channel *Channel `json:"channel"`

	// Guild 群组对象
	Guild *Guild `json:"guild"`

	// Member 成员对象
	Member *GuildMember `json:"member"`

	// User 用户对象
	User *User `json:"user"`

	// CreatedAt 消息发送的时间戳
	CreatedAt int64 `json:"created_at"`

	// UpdatedAt 消息修改的时间戳
	UpdatedAt int64 `json:"updated_at"`
}

Message 消息.

type OpCode

type OpCode = int64
const (
	OpCodeEvent OpCode = iota
	OpCodePing
	OpCodePong
	OpCodeIdentify
	OpCodeReady
)

type Ready

type Ready struct {
	Logins []Login `json:"logins"`
}

Ready defines model for Ready.

type Signal

type Signal[T Event | Identify | Ready] struct {
	// 信令类型
	Op OpCode `json:"op"`

	// 信令数据
	Body T `json:"body,omitempty"`
}

Signal defines model for Signal.

type User

type User struct {
	// ID 用户 ID
	ID string `json:"id"`

	// Name 用户名称
	Name string `json:"name"`

	// Avatar 用户头像
	Avatar string `json:"avatar"`

	// IsBot 是否为机器人
	IsBot bool `json:"is_bot"`
}

User 用户.

Jump to

Keyboard shortcuts

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