pixelplace

package module
v0.0.0-...-0a87d2a Latest Latest
Warning

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

Go to latest
Published: May 26, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

README

Pixelplace Go

Warning -> this is a work in progress.

go wrapper for pixelplace.io

Installation

go get github.com/monkeyskid/Pixelplace

Documentation

Index

Constants

View Source
const (
	WebsocketEndpoint   = "wss://pixelplace.io/socket.io/?EIO=3&transport=websocket"
	GetUserEndpoint     = "https://pixelplace.io/api/get-user.php?username="
	FriendEndpoint      = "https://pixelplace.io/api/post-friend.php"
	GetPaintingEndpoint = "https://pixelplace.io/api/get-painting.php?connected=1&id="
	JoinGuildEndpoint   = "https://pixelplace.io/api/post-guild-access.php"
	BaseEndpoint        = "https://pixelplace.io"
)
View Source
const (
	PlacePixelEvent        string = "p"
	PingAliveEvent         string = "ping.alive"
	PongAliveEvent         string = "pong.alive"
	SendChatMessageEvent   string = "chat.message"
	AuthorizeEvent         string = "init"
	ChatMessageLoadedEvent string = "chat.user.message"
	PlayerJoinEvent        string = "j"
	PlayerLeaveEvent       string = "l"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddFriendResponse

type AddFriendResponse struct {
	Changed int `json:"changed"`
}

type AuthorizeRequest

type AuthorizeRequest struct {
	AuthKey   string `json:"authKey"`
	AuthToken string `json:"authToken"`
	AuthId    string `json:"authId"`
	BoardId   int    `json:"boardId"`
}

type ChatMessageRequest

type ChatMessageRequest struct {
	Text    string   `json:"text"`
	Mention string   `json:"mention"`
	Type    ChatType `json:"type"`
	Target  string   `json:"target"`
	Color   int      `json:"color"`
}

type ChatType

type ChatType string
const (
	GlobalChat   ChatType = "global"
	PaintingChat ChatType = "painting"
)

type Client

type Client struct {
	Painting struct {
		Id          int
		Name        string
		Description string
		Rules       string
		Width       int
		Height      int
		Owner       struct {
			Id       int
			Username string
		}
		Moderators      []string
		CreatedAt       time.Time
		DiscordRequired bool
		Pixels          int64
		BrushSize       int
		Cooldown        int
	}
	User struct {
		Id        int
		Username  string
		AuthId    string
		AuthKey   string
		AuthToken string
		Premium   bool
		Staff     bool
		ChatMod   bool
		Friends   []string
		Blocked   []string
		HasEmail  bool
		Coins     int
	}
	PlacingInterval time.Duration
	// contains filtered or unexported fields
}

func New

func New(authId, authKey, authToken string) *Client

func (*Client) AddFriend

func (c *Client) AddFriend(username string) error

AddFriend adds the user to the friend list.

func (*Client) Close

func (c *Client) Close() error

Close closes the connection to the server.

func (*Client) Connect

func (c *Client) Connect(boardId int) error

Connect opens a connection to the server.

func (*Client) GetUser

func (c *Client) GetUser(username string) (*User, error)

GetUser fetches the users profile.

func (*Client) JoinGuild

func (c *Client) JoinGuild(id string) error

func (*Client) OnChatMessage

func (c *Client) OnChatMessage(fn func(*Client, *Message))

func (*Client) OnPixelPlaced

func (c *Client) OnPixelPlaced(fn func(*Client, *Placed))

func (*Client) OnPlayerJoin

func (c *Client) OnPlayerJoin(fn func(*Client, *Player))

func (*Client) OnPlayerLeave

func (c *Client) OnPlayerLeave(fn func(*Client, *Player))

func (*Client) PlacePixel

func (c *Client) PlacePixel(x, y, color int) error

PlacePixel places a pixel on the current painting.

func (*Client) RemoveFriend

func (c *Client) RemoveFriend(username string) error

RemoveFriend removes the user to the friend list.

func (*Client) SendChatMessage

func (c *Client) SendChatMessage(content string, chat ChatType, color int) error

SendChatMessage sends a chat message.

type FormatData

type FormatData interface {
	[][]int | string | interface{}
}

type GetPaintingResponse

type GetPaintingResponse struct {
	Painting struct {
		ID          int    `json:"id"`
		Name        string `json:"name"`
		Description string `json:"description"`
		Rules       string `json:"rules"`
		Width       int    `json:"width"`
		Height      int    `json:"height"`
		Cooldown    int    `json:"cooldown"`
		Owner       struct {
			ID       int    `json:"id"`
			Username string `json:"name"`
		} `json:"owner"`
		Moderators      []string `json:"moderators"`
		CreatedAt       string   `json:"createdAt"`
		DiscordRequired bool     `json:"discordRequired"`
		Pixels          int64    `json:"pixels"`
		Brush           struct {
			Size int `json:"size"`
		} `json:"brush"`
	} `json:"painting"`
	User struct {
		ID      int    `json:"id"`
		Name    string `json:"name"`
		Key     string `json:"key"`
		Coins   int    `json:"ppcoins"`
		Premium struct {
			Active bool `json:"active"`
		} `json:"premium"`
		IsStaff   bool     `json:"isStaff"`
		IsChatMod bool     `json:"isChatMod"`
		Friends   []string `json:"friends"`
		Blocked   []string `json:"blocked"`
		HasEmail  bool     `json:"hasEmail"`
	} `json:"user"`
}

type Message

type Message struct {
	Username  string    `json:"username"`
	Color     int       `json:"color"`
	Guild     string    `json:"guild"`
	Message   string    `json:"message"`
	Admin     bool      `json:"admin"`
	Mod       bool      `json:"mod"`
	Chatmod   bool      `json:"chatmod"`
	Premium   bool      `json:"premium"`
	Rainbow   bool      `json:"rainbow"`
	Channel   string    `json:"channel"`
	Mention   string    `json:"mention"`
	Target    string    `json:"target"`
	Type      string    `json:"type"`
	CreatedAt time.Time `json:"createdAt"`
}

type Placed

type Placed struct {
	X     int
	Y     int
	Color int
}

type Player

type Player struct {
	Username string
}

type User

type User struct {
	Username        string
	Followers       int
	Bio             string
	CreatedAt       time.Time
	LastLogin       time.Time
	Pixels          int
	Admin           bool
	Mod             bool
	ChatMod         bool
	Vip             bool
	Socials         []string
	UsernameHistory []string
	Guild           string
	BanReason       string
}

type UserResponse

type UserResponse struct {
	Username  string   `json:"username"`
	Followers int      `json:"followers"`
	Bio       string   `json:"bio"`
	CreatedAt string   `json:"createdAt"`
	LastLogin string   `json:"lastLogin"`
	Pixels    int      `json:"pixels"`
	Admin     int      `json:"admin"`
	Mod       int      `json:"mod"`
	Chatmod   int      `json:"chatmod"`
	Guild     string   `json:"guild"`
	Vip       int      `json:"vip"`
	BanReason string   `json:"banReason"`
	Social    []string `json:"social"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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