mcqq

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2025 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const MaxRCONPackageSize = 4096

Variables

View Source
var GroupList []int64
View Source
var McBots = make(map[string]*MinecraftBot)
View Source
var PluginConfig = Config{}

Functions

func GroupRule

func GroupRule(ctx *zero.Ctx) bool

Types

type BaseComponent

type BaseComponent struct {
	// 加粗
	Bold *bool `json:"bold,omitempty"`
	// 颜色
	Color Color `json:"color,omitempty"`
	// 字体
	Font *string `json:"font,omitempty"`
	// 插入其他内容,未测试
	Insertion *string `json:"insertion,omitempty"`
	// 斜体
	Italic *bool `json:"italic,omitempty"`
	// 模糊的,未测试
	Obfuscated *bool `json:"obfuscated,omitempty"`
	// 删除线
	Strikethrough *bool `json:"strikethrough,omitempty"`
	// 文本
	Text string `json:"text"`
	// 下划线
	Underlined *bool `json:"underlined,omitempty"`
}

BaseComponent ...

type BaseMessageEvent

type BaseMessageEvent struct {
	EventName     string     `json:"event_name"`
	ServerType    string     `json:"server_type"`
	ServerVersion string     `json:"server_version"`
	Message       string     `json:"message"`
	MessageID     string     `json:"message_id"`
	Player        BasePlayer `json:"player"`
	PostType      string     `json:"post_type"`
	ServerName    string     `json:"server_name"`
	SubType       string     `json:"sub_type"`
	Timestamp     int64      `json:"timestamp"`
}

BaseMessageEvent ...

type BaseNoticeEvent

type BaseNoticeEvent struct {
	EventName  string     `json:"event_name"`
	Player     BasePlayer `json:"player"`
	PostType   string     `json:"post_type"`
	ServerName string     `json:"server_name"`
	SubType    string     `json:"sub_type"`
	Timestamp  int64      `json:"timestamp"`
}

BaseNoticeEvent ...

type BasePlayer

type BasePlayer struct {
	IsOp     *bool   `json:"is_op,omitempty"`
	Nickname string  `json:"nickname"`
	UUID     *string `json:"uuid,omitempty"`
}

BasePlayer ...

type ClickEvent

type ClickEvent struct {
	// 行为
	Action ClickEventAction `json:"action"`
	// 值
	Value string `json:"value,omitempty"`
}

ClickEvent ...

type ClickEventAction

type ClickEventAction string

ClickEventAction ...

const (
	ChangePage      ClickEventAction = "change_page"
	CopyToClipboard ClickEventAction = "copy_to_clipboard"
	OpenFile        ClickEventAction = "open_file"
	OpenURL         ClickEventAction = "open_url"
	RunCommand      ClickEventAction = "run_command"
	SuggestCommand  ClickEventAction = "suggest_command"
)

type Color

type Color string
const (
	Black       Color = "black"
	DarkBlue    Color = "dark_blue"
	DarkGreen   Color = "dark_green"
	DarkAqua    Color = "dark_aqua"
	DarkRed     Color = "dark_red"
	DarkPurple  Color = "dark_purple"
	Gold        Color = "gold"
	Gray        Color = "gray"
	DarkGray    Color = "dark_gray"
	Blue        Color = "blue"
	Green       Color = "green"
	Aqua        Color = "aqua"
	Red         Color = "red"
	LightPurple Color = "light_purple"
	Yellow      Color = "yellow"
	White       Color = "white"
)

type Config

type Config struct {
	Host            string
	Port            int
	ForwardUrlList  []ForwardServer
	ServerMap       map[string]Server
	CommandPriority int
	AccessToken     string
}

type ForwardServer

type ForwardServer struct {
	ServerName string
	Url        string
}

type Group

type Group struct {
	GroupId int64
	BotId   int64
}

type HoverEntity

type HoverEntity struct {
	ID   string        `json:"id,omitempty"`
	Name BaseComponent `json:"name,omitempty"`
	Type string        `json:"type,omitempty"`
}

HoverEntity ...

type HoverEvent

type HoverEvent struct {
	Action HoverEventAction `json:"action"`
	Entity *HoverEntity     `json:"entity,omitempty"`
	Item   *HoverItem       `json:"item,omitempty"`
	Text   []BaseComponent  `json:"text,omitempty"`
}

HoverEvent ...

type HoverEventAction

type HoverEventAction string
const (
	ShowEntity HoverEventAction = "show_entity"
	ShowItem   HoverEventAction = "show_item"
	ShowText   HoverEventAction = "show_text"
)

type HoverItem

type HoverItem struct {
	Count int64  `json:"count,omitempty"`
	ID    string `json:"id,omitempty"`
	Tag   string `json:"tag,omitempty"`
}

HoverItem ...

type MessageData

type MessageData struct {
	Message []MessageSegment `json:"message"`
}

type MessageSegment

type MessageSegment struct {
	Data interface{} `json:"data"`
	Type string      `json:"type"`
}

MessageSegment ...

type MinecraftBot

type MinecraftBot struct {
	Websocket  *websocket.Conn
	RconClient *RCONClientConn
}

type RCONClientConn

type RCONClientConn interface {
	Cmd(cmd string) error
	Resp() (resp string, err error)
	Close() error
}

func DialRCON

func DialRCON(addr string, password string) (client RCONClientConn, err error)

DialRCON connect to a RCON server and return the connection after login. We promise the returned RCONClientConn is an RCONConn, so you can convert them by type assertions if you need call the ReadPacket() or WritePacket() methods.

type RCONConn

type RCONConn struct {
	net.Conn
	ReqID int32
}

func (*RCONConn) AcceptCmd

func (r *RCONConn) AcceptCmd() (string, error)

func (*RCONConn) AcceptLogin

func (r *RCONConn) AcceptLogin(password string) error

func (*RCONConn) Cmd

func (r *RCONConn) Cmd(cmd string) error

func (*RCONConn) ReadPacket

func (r *RCONConn) ReadPacket() (RequestID, Type int32, Payload string, err error)

func (*RCONConn) Resp

func (r *RCONConn) Resp() (resp string, err error)

func (*RCONConn) RespCmd

func (r *RCONConn) RespCmd(resp string) error

func (*RCONConn) WritePacket

func (r *RCONConn) WritePacket(RequestID, Type int32, Payload string) error

type RCONListener

type RCONListener struct{ net.Listener }

func ListenRCON

func ListenRCON(addr string) (*RCONListener, error)

ListenRCON announces on the local network address, accepting RCON clients.

func (*RCONListener) Accept

func (r *RCONListener) Accept() (RCONServerConn, error)

Accept RCON connection for client. We promise the returned RCONServerConn is an RCONConn, so you can convert them by type assertions if you need call the ReadPacket() or WritePacket() methods.

type RCONServerConn

type RCONServerConn interface {
	AcceptLogin(password string) error
	AcceptCmd() (cmd string, err error)
	RespCmd(resp string) error
	Close() error
}

RCONServerConn is the connection in the server side.

type Server

type Server struct {
	GroupList []Group
	RconMsg   bool
	RconCmd   bool
}

type TextComponent

type TextComponent struct {
	// 加粗
	Bold *bool `json:"bold,omitempty"`
	// 点击事件
	ClickEvent *ClickEvent `json:"click_event,omitempty"`
	// 颜色
	Color Color `json:"color,omitempty"`
	// 字体
	Font *string `json:"font,omitempty"`
	// 悬停事件
	HoverEvent *HoverEvent `json:"hover_event,omitempty"`
	// 插入其他内容,未测试
	Insertion *string `json:"insertion,omitempty"`
	// 斜体
	Italic *bool `json:"italic,omitempty"`
	// 模糊的,未测试
	Obfuscated *bool `json:"obfuscated,omitempty"`
	// 删除线
	Strikethrough *bool `json:"strikethrough,omitempty"`
	// 文本
	Text string `json:"text"`
	// 下划线
	Underlined *bool `json:"underlined,omitempty"`
}

TextComponent ...

type WebsocketData

type WebsocketData struct {
	API  string `json:"api"`
	Data any    `json:"data"`
}

WebsocketData ...

Jump to

Keyboard shortcuts

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