ttapi

package module
v0.0.0-...-65e1807 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: MIT Imports: 17 Imported by: 0

README

Turntable API


Join us on Discord https://discord.gg/4AA2DqWpVc


A simple go wrapper for the turntable API.
You'll need to find your AUTH, USERID and ROOMID information with this bookmarklet.

Installation

go get github.com/alaingilbert/ttapi

Examples

Chat bot

This bot responds to anybody who writes "/hello" in the chat.

package main

import (
    "os"
    "github.com/alaingilbert/ttapi"
)

func main() {
    auth := os.Getenv("TTAPI_AUTH")
    userID := os.Getenv("TTAPI_USER_ID")
    roomID := os.Getenv("TTAPI_ROOM_ID")
    bot := ttapi.NewBot(auth, userID, roomID)
    bot.OnSpeak(func(evt ttapi.SpeakEvt) {
        if evt.Text == "/hello" {
            _ = bot.Speakf("Hey! How are you @%s ?", evt.Name)
        }
    })
    bot.Start()
}

More examples here -> https://github.com/alaingilbert/ttapi/tree/master/examples

Debugging

Add the following line in your main function

logrus.SetLevel(logrus.DebugLevel)

That will print on the terminal all the data that you get and all the data that you send.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateToken

func GenerateToken() string

GenerateToken generate a random 32 bytes hex token

func SGo

func SGo(fn func())

SGo stands for Safe Go or Shit Go depending how you feel about goroutine panic handling Basically just a wrapper around the built-in keyword "go" with crash recovery

func Sha1

func Sha1(in []byte) string

Sha1 returns sha1 hex sum as a string

Types

type AddDJEvt

type AddDJEvt struct {
	DjEvt
}

AddDJEvt ...

type BaseRes

type BaseRes struct {
	Msgid   int    `json:"msgid"`
	Success bool   `json:"success"`
	Err     string `json:"err"`
}

BaseRes ...

func (*BaseRes) SetError

func (b *BaseRes) SetError(err error)

SetError ...

type BootedUserEvt

type BootedUserEvt struct {
	Success bool        `json:"success"`
	Userid  string      `json:"userid"`
	Reason  interface{} `json:"reason"`
	Command string      `json:"command"`
	Modid   string      `json:"modid"`
	Roomid  string      `json:"roomid"`
}

BootedUserEvt ...

type Bot

type Bot struct {
	CurrentSongID string // cached current song id
	CurrentDjID   string // cached current dj id
	// contains filtered or unexported fields
}

Bot is a thread safe client for turntable \o/ To get the auth, user id and room id, you can use the following bookmarklet http://alaingilbert.github.io/Turntable-API/bookmarklet.html

func NewBot

func NewBot(auth, userID, roomID string) *Bot

NewBot creates a new bot

func (*Bot) AddDj

func (b *Bot) AddDj() error

AddDj step up as a DJ

func (*Bot) AddFavorite

func (b *Bot) AddFavorite(roomID string) error

AddFavorite add a room to your favorite rooms

func (*Bot) AddModerator

func (b *Bot) AddModerator(userID string) error

AddModerator adds a moderator

func (*Bot) BecomeFan

func (b *Bot) BecomeFan(userID string) error

BecomeFan fan someone

func (*Bot) BootUser

func (b *Bot) BootUser(userID, reason string) error

BootUser kick a user out of the room

func (*Bot) Bop

func (b *Bot) Bop() error

Bop alis to VoteUp

func (*Bot) DirectoryGraph

func (b *Bot) DirectoryGraph() (DirectoryGraphRes, error)

DirectoryGraph get the location of your friends/idols

func (*Bot) GetAvatarIDs

func (b *Bot) GetAvatarIDs() ([]int, error)

GetAvatarIDs get the avatar ids that you can currently use

func (*Bot) GetFanOf

func (b *Bot) GetFanOf(userID string) (GetFanOfRes, error)

GetFanOf gets the list of everyone the specified userID is a fan of, or the list of everyone you are a fan of if a userID is not specified

func (*Bot) GetFans

func (b *Bot) GetFans() (GetFansRes, error)

GetFans get the list of everyone who is a fan of you

func (*Bot) GetFavorites

func (b *Bot) GetFavorites() (GetFavoritesRes, error)

GetFavorites get your favorite rooms

func (*Bot) GetPresence

func (b *Bot) GetPresence(userID string) (GetPresenceRes, error)

GetPresence get presence for the specified user, or your presence if a userID is not specified

func (*Bot) GetProfile

func (b *Bot) GetProfile(userID string) (GetProfileRes, error)

GetProfile given a UserID, gets a user profile

func (*Bot) GetUserID

func (b *Bot) GetUserID(name string) (id string, err error)

GetUserID gets a user's ID by their name

func (*Bot) ModifyLaptop

func (b *Bot) ModifyLaptop(laptop string) error

ModifyLaptop set your laptop

func (*Bot) ModifyName

func (b *Bot) ModifyName(newName string) error

ModifyName changes your name

func (*Bot) On

func (b *Bot) On(cmd string, clb func([]byte))

On triggered when "cmd" is received

func (*Bot) OnAddDJ

func (b *Bot) OnAddDJ(clb func(AddDJEvt))

OnAddDJ triggered when a user takes a dj spot

func (*Bot) OnBootedUser

func (b *Bot) OnBootedUser(clb func(BootedUserEvt))

OnBootedUser triggered when a user gets booted

func (*Bot) OnDeregistered

func (b *Bot) OnDeregistered(clb func(DeregisteredEvt))

OnDeregistered triggered when a user leaves the room

func (*Bot) OnEndSong

func (b *Bot) OnEndSong(clb func(RoomInfoRes))

OnEndSong triggered at the end of the song. (Just before the newsong/nosong event) The data returned by this event contains information about the song that has just ended.

func (*Bot) OnEscort

func (b *Bot) OnEscort(clb func(EscortEvt))

OnEscort triggered when a user is escorted off the stage

func (*Bot) OnNewModerator

func (b *Bot) OnNewModerator(clb func(NewModeratorEvt))

OnNewModerator triggered when a user is promoted to a moderator

func (*Bot) OnNewSong

func (b *Bot) OnNewSong(clb func(NewSongEvt))

OnNewSong triggered when a new song starts

func (*Bot) OnNoSong

func (b *Bot) OnNoSong(clb func(evt NoSongEvt))

OnNoSong triggered when there is no song

func (*Bot) OnPmmed

func (b *Bot) OnPmmed(clb func(PmmedEvt))

OnPmmed triggered when a private message is received

func (*Bot) OnReady

func (b *Bot) OnReady(clb func())

OnReady triggered when the bot is connected

func (*Bot) OnRegistered

func (b *Bot) OnRegistered(clb func(RegisteredEvt))

OnRegistered triggered when someone enter the room

func (*Bot) OnRemDJ

func (b *Bot) OnRemDJ(clb func(RemDJEvt))

OnRemDJ triggered when a user leaves a dj spot

func (*Bot) OnRemModerator

func (b *Bot) OnRemModerator(clb func(RemModeratorEvt))

OnRemModerator triggered when a user loses their moderator title

func (*Bot) OnRoomChanged

func (b *Bot) OnRoomChanged(clb func(RoomInfoRes))

OnRoomChanged triggered when the bot enter a room

func (*Bot) OnSnagged

func (b *Bot) OnSnagged(clb func(SnaggedEvt))

OnSnagged triggered when a user snag the currently playing song

func (*Bot) OnSpeak

func (b *Bot) OnSpeak(clb func(SpeakEvt))

OnSpeak triggered when a message is received in the public chat

func (*Bot) OnUpdateUser

func (b *Bot) OnUpdateUser(clb func([]byte))

OnUpdateUser triggered when a user updates their name/profile

func (*Bot) OnUpdateVotes

func (b *Bot) OnUpdateVotes(clb func(UpdateVotesEvt))

OnUpdateVotes triggered when a user vote Note: the userid is provided only if the user votes up, or later changes their mind and votes down

func (*Bot) PM

func (b *Bot) PM(userID, msg string) error

PM sends a private message

func (*Bot) PlaylistAdd

func (b *Bot) PlaylistAdd(songID, playlistName string, idx int) error

PlaylistAdd adds a song to a playlist songID will default to the current song id playlistName will default to "default" idx will default to 0

func (*Bot) PlaylistAll

func (b *Bot) PlaylistAll(playlistName string) (PlaylistAllRes, error)

PlaylistAll get all information about a playlist

func (*Bot) PlaylistCreate

func (b *Bot) PlaylistCreate(playlistName string) error

PlaylistCreate creates a new playlist

func (*Bot) PlaylistDelete

func (b *Bot) PlaylistDelete(playlistName string) error

PlaylistDelete deletes a playlist

func (*Bot) PlaylistListAll

func (b *Bot) PlaylistListAll() (PlaylistListAllRes, error)

PlaylistListAll list all your playlists

func (*Bot) PlaylistRemove

func (b *Bot) PlaylistRemove(playlistName string, idx int) error

PlaylistRemove remove a song from a playlist

func (*Bot) PlaylistRename

func (b *Bot) PlaylistRename(oldPlaylistName, newPlaylistName string) error

PlaylistRename rename a playlist

func (*Bot) PlaylistReorder

func (b *Bot) PlaylistReorder(playlistName string, idxFrom, idxTo int) error

PlaylistReorder reorder a playlist. Take the song at index idxFrom and move it to index idxTo.

func (*Bot) PlaylistSwitch

func (b *Bot) PlaylistSwitch(playlistName string) error

PlaylistSwitch switch to another playlist

func (*Bot) RemDj

func (b *Bot) RemDj(userID string) error

RemDj remove userID from DJ spot | or yourself if userID is empty

func (*Bot) RemFavorite

func (b *Bot) RemFavorite(roomID string) error

RemFavorite remove a room from your favorite rooms

func (*Bot) RemModerator

func (b *Bot) RemModerator(userID string) error

RemModerator remove a moderator

func (*Bot) RemoveFan

func (b *Bot) RemoveFan(userID string) error

RemoveFan unfan someone

func (*Bot) RoomDeregister

func (b *Bot) RoomDeregister() error

RoomDeregister exit the current room

func (*Bot) RoomInfo

func (b *Bot) RoomInfo() (RoomInfoRes, error)

RoomInfo gets information about the current room

func (*Bot) RoomInfoHashMap

func (b *Bot) RoomInfoHashMap() (H, error)

RoomInfoHashMap gets information about the current room

func (*Bot) RoomRegister

func (b *Bot) RoomRegister(roomID string) error

RoomRegister register in a room

func (*Bot) Search

func (b *Bot) Search(query string) (SearchRes, error)

Search for a song

func (*Bot) SetAvatar

func (b *Bot) SetAvatar(avatarID int) error

SetAvatar set your avatar

func (*Bot) SetBot

func (b *Bot) SetBot() error

SetBot makes your user a bot. WARNING: Once user is changed to a bot it cannot be undone!

func (*Bot) SetStatus

func (b *Bot) SetStatus(status string) error

SetStatus sets your current status

func (*Bot) Skip

func (b *Bot) Skip() error

Skip is an alias to StopSong

func (*Bot) Snag

func (b *Bot) Snag() error

Snag trigger the heart animation used to show that you've snagged the currently playing song.

Warning This function will not add the song into the queue. Use PlaylistAdd to queue the song, and if successful, then use Snag to trigger the animation.

func (*Bot) Speak

func (b *Bot) Speak(msg string) error

Speak send a message in the public chat

func (*Bot) Speakf

func (b *Bot) Speakf(format string, args ...interface{}) error

Speakf alias to Speak with formatted arguments

func (*Bot) Start

func (b *Bot) Start()

Start the bot

func (*Bot) Stop

func (b *Bot) Stop()

Stop the bot

func (*Bot) StopSong

func (b *Bot) StopSong() error

StopSong skip the song you are currently playing

func (*Bot) UserAvailableAvatars

func (b *Bot) UserAvailableAvatars() (UserAvailableAvatarsRes, error)

UserAvailableAvatars get all available avatars

func (*Bot) UserInfo

func (b *Bot) UserInfo() (UserInfoRes, error)

UserInfo returns the information about the user

func (*Bot) UserModify

func (b *Bot) UserModify(h H) error

UserModify ...

func (*Bot) VoteDown

func (b *Bot) VoteDown() error

VoteDown vote down the ongoing song

func (*Bot) VoteUp

func (b *Bot) VoteUp() error

VoteUp vote up the ongoing song

type DeregisteredEvt

type DeregisteredEvt struct {
	Command string `json:"command"`
	Roomid  string `json:"roomid"`
	User    []struct {
		Fanofs  int     `json:"fanofs"`
		Name    string  `json:"name"`
		Created float64 `json:"created"`
		Laptop  string  `json:"laptop"`
		Userid  string  `json:"userid"`
		ACL     float64 `json:"acl"`
		Fans    int     `json:"fans"`
		Points  int     `json:"points"`
		Images  struct {
			Fullfront string `json:"fullfront"`
			Headfront string `json:"headfront"`
		} `json:"images"`
		ID         string  `json:"_id"`
		Avatarid   int     `json:"avatarid"`
		Registered float64 `json:"registered"`
	} `json:"user"`
	Success bool `json:"success"`
}

DeregisteredEvt ...

type DirectoryGraphRes

type DirectoryGraphRes struct {
	BaseRes
	Rooms [][]interface{} `json:"rooms"`
}

DirectoryGraphRes ...

type DjEvt

type DjEvt struct {
	Djs struct {
		Num0 string `json:"0"`
		Num1 string `json:"1"`
		Num2 string `json:"2"`
		Num3 string `json:"3"`
		Num4 string `json:"4"`
	} `json:"djs"`
	Success bool   `json:"success"`
	Command string `json:"command"`
	User    []struct {
		Fanofs  int     `json:"fanofs"`
		Name    string  `json:"name"`
		Created float64 `json:"created"`
		Laptop  string  `json:"laptop"`
		Userid  string  `json:"userid"`
		ACL     float64 `json:"acl"`
		Fans    int     `json:"fans"`
		Points  int     `json:"points"`
		Images  struct {
			Fullfront string `json:"fullfront"`
			Headfront string `json:"headfront"`
		} `json:"images"`
		ID         string  `json:"_id"`
		Avatarid   int     `json:"avatarid"`
		Registered float64 `json:"registered"`
	} `json:"user"`
	Roomid     string        `json:"roomid"`
	Placements []interface{} `json:"placements"`
	Modid      string        `json:"modid"`
}

DjEvt ...

type EscortEvt

type EscortEvt struct {
	DjEvt
}

type GetFanOfRes

type GetFanOfRes struct {
	BaseRes
	FanOf []string `json:"fanof"`
}

GetFanOfRes ...

type GetFansRes

type GetFansRes struct {
	BaseRes
	Fans []string `json:"fans"`
}

GetFansRes ...

type GetFavoritesRes

type GetFavoritesRes struct {
	BaseRes
	List []string `json:"list"`
}

GetFavoritesRes ...

type GetPresenceRes

type GetPresenceRes struct {
	BaseRes
	Presence struct {
		Status string `json:"status"`
		UserID string `json:"userid"`
	} `json:"presence"`
}

GetPresenceRes ...

type GetProfileRes

type GetProfileRes struct {
	BaseRes
	Name       string  `json:"name"`
	Created    float64 `json:"created"`
	Laptop     string  `json:"laptop"`
	Userid     string  `json:"userid"`
	Registered float64 `json:"registered"`
	ACL        float64 `json:"acl"`
	Fans       int     `json:"fans"`
	Points     int     `json:"points"`
	Images     struct {
		Fullfront string `json:"fullfront"`
		Headfront string `json:"headfront"`
	} `json:"images"`
	ID       string `json:"_id"`
	Avatarid int    `json:"avatarid"`
	Fanofs   int    `json:"fanofs"`
}

GetProfileRes ...

type GetUserIDRes

type GetUserIDRes struct {
	BaseRes
	UserID string `json:"userid"`
}

GetUserIDRes ...

type H

type H map[string]interface{}

H is a hashmap

type IBaseRes

type IBaseRes interface {
	SetError(error)
}

IBaseRes ...

type IBot

type IBot interface {
	On(cmd string, clb func([]byte))
	OnAddDJ(func(AddDJEvt))
	OnBootedUser(func(BootedUserEvt))
	OnDeregistered(func(DeregisteredEvt))
	OnEndSong(func(H))
	OnEscort(func(EscortEvt))
	OnNewModerator(func(NewModeratorEvt))
	OnNewSong(func(NewSongEvt))
	OnNoSong(func(NoSongEvt))
	OnPmmed(func(PmmedEvt))
	OnRegistered(func(RegisteredEvt))
	OnRemDJ(func(RemDJEvt))
	OnRemModerator(func(RemModeratorEvt))
	OnRoomChanged(func(RoomInfoRes))
	OnSnagged(func(SnaggedEvt))
	OnSpeak(func(SpeakEvt))
	OnReady(func())
	OnUpdateUser(func([]byte))
	OnUpdateVotes(func(UpdateVotesEvt))

	AddDj() error
	AddFavorite(roomID string) error
	AddModerator(userID string) error
	BecomeFan(userID string) error
	BootUser(userID, reason string) error
	Bop() error
	DirectoryGraph() (DirectoryGraphRes, error)
	GetAvatarIDs() ([]int, error)
	GetFavorites() (GetFavoritesRes, error)
	GetFanOf(userID string) (GetFanOfRes, error)
	GetFans() (GetFansRes, error)
	GetPresence(userID string) (GetPresenceRes, error)
	GetProfile(userID string) (GetProfileRes, error)
	GetUserID(name string) (string, error)
	SetStatus(status string) error
	ModifyLaptop(laptop string) error
	ModifyName(newName string) error
	PlaylistAdd(songID, playlistName string, idx int) error
	PlaylistAll(playlistName string) (PlaylistAllRes, error)
	PlaylistCreate(playlistName string) error
	PlaylistDelete(playlistName string) error
	PlaylistListAll() (PlaylistListAllRes, error)
	PlaylistRemove(playlistName string, idx int) error
	PlaylistRename(oldPlaylistName, newPlaylistName string) error
	PlaylistReorder(playlistName string, idxFrom, idxTo int) error
	PlaylistSwitch(playlistName string) error
	PM(userID, msg string) error
	RemDj(userID string) error
	RemModerator(userID string) error
	RemFavorite(roomID string) error
	RemoveFan(userID string) error
	RoomDeregister() error
	RoomInfo() (RoomInfoRes, error)
	RoomRegister(roomID string) error
	Search(query string) (SearchRes, error)
	SetAvatar(avatarID int) error
	Skip() error
	Snag() error
	Speak(msg string) error
	Speakf(format string, args ...interface{}) error
	Start()
	Stop()
	StopSong() error
	UserAvailableAvatars() (UserAvailableAvatarsRes, error)
	UserInfo() (UserInfoRes, error)
	UserModify(H) error
	VoteDown() error
	VoteUp() error
}

IBot ...

type NewModeratorEvt

type NewModeratorEvt struct {
	Command string `json:"command"`
	UserID  string `json:"userid"`
	RoomID  string `json:"roomid"`
	Success bool   `json:"success"`
	Modid   string `json:"modid"`
}

NewModeratorEvt ... {"modid": "604173683f4bfc001c3a57d0", "roomid": "604064503f4bfc001be4c57b", "userid": "60b950ebb5178a0013a1e4a0", "command": "new_moderator", "success": true}

type NewSongEvt

type NewSongEvt struct {
	Command string  `json:"command"`
	Now     float64 `json:"now"`
	Roomid  string  `json:"roomid"`
	Room    struct {
		Chatserver []interface{} `json:"chatserver"`
		Name       string        `json:"name"`
		Created    float64       `json:"created"`
		Shortcut   string        `json:"shortcut"`
		Roomid     string        `json:"roomid"`
		Metadata   struct {
			Songlog []struct {
				Source   string  `json:"source"`
				Sourceid string  `json:"sourceid"`
				Created  float64 `json:"created"`
				Djid     string  `json:"djid"`
				Score    float64 `json:"score,omitempty"`
				Djname   string  `json:"djname"`
				ID       string  `json:"_id"`
				Metadata struct {
					Coverart string `json:"coverart"`
					Length   int    `json:"length"`
					Artist   string `json:"artist"`
					Song     string `json:"song"`
				} `json:"metadata"`
			} `json:"songlog"`
			DjFull               bool     `json:"dj_full"`
			Djs                  []string `json:"djs"`
			ScreenUploadsAllowed bool     `json:"screen_uploads_allowed"`
			CurrentSong          struct {
				Playlist  string  `json:"playlist"`
				Created   float64 `json:"created"`
				Sourceid  string  `json:"sourceid"`
				Source    string  `json:"source"`
				Djname    string  `json:"djname"`
				Starttime float64 `json:"starttime"`
				ID        string  `json:"_id"`
				Djid      string  `json:"djid"`
				Metadata  struct {
					Coverart string `json:"coverart"`
					Length   int    `json:"length"`
					Song     string `json:"song"`
					Artist   string `json:"artist"`
				} `json:"metadata"`
			} `json:"current_song"`
			Privacy     string        `json:"privacy"`
			MaxDjs      int           `json:"max_djs"`
			Downvotes   int           `json:"downvotes"`
			Userid      string        `json:"userid"`
			Listeners   int           `json:"listeners"`
			Featured    bool          `json:"featured"`
			Djcount     int           `json:"djcount"`
			CurrentDj   string        `json:"current_dj"`
			Djthreshold int           `json:"djthreshold"`
			ModeratorID []string      `json:"moderator_id"`
			Upvotes     int           `json:"upvotes"`
			MaxSize     int           `json:"max_size"`
			Votelog     []interface{} `json:"votelog"`
		} `json:"metadata"`
	} `json:"room"`
	Success bool `json:"success"`
}

NewSongEvt ...

type NoSongEvt

type NoSongEvt struct {
	Command string `json:"command"`
	Room    struct {
		Name      string  `json:"name"`
		Created   float64 `json:"created"`
		Shortcut  string  `json:"shortcut"`
		NameLower string  `json:"name_lower"`
		Roomid    string  `json:"roomid"`
		Metadata  struct {
			DjFull      bool          `json:"dj_full"`
			Djs         []interface{} `json:"djs"`
			Upvotes     int           `json:"upvotes"`
			Privacy     string        `json:"privacy"`
			MaxDjs      int           `json:"max_djs"`
			Downvotes   int           `json:"downvotes"`
			Random      float64       `json:"random"`
			Userid      string        `json:"userid"`
			Listeners   int           `json:"listeners"`
			Djcount     int           `json:"djcount"`
			MaxSize     int           `json:"max_size"`
			Djthreshold int           `json:"djthreshold"`
			ModeratorID []string      `json:"moderator_id"`
			CurrentSong interface{}   `json:"current_song"`
			CurrentDj   interface{}   `json:"current_dj"`
			Votelog     []interface{} `json:"votelog"`
		} `json:"metadata"`
	} `json:"room"`
	Success bool `json:"success"`
}

NoSongEvt ...

type PlaylistAllRes

type PlaylistAllRes struct {
	BaseRes
	List []struct {
		Sourceid string `json:"sourceid"`
		Source   string `json:"source"`
		ID       string `json:"_id"`
		Metadata struct {
			Coverart string `json:"coverart"`
			Length   int    `json:"length"`
			Song     string `json:"song"`
			Artist   string `json:"artist"`
		} `json:"metadata"`
		Created float64 `json:"created"`
	} `json:"list"`
}

PlaylistAllRes ...

type PlaylistListAllRes

type PlaylistListAllRes struct {
	BaseRes
	List []struct {
		Active bool   `json:"active"`
		Name   string `json:"name"`
	} `json:"list"`
}

PlaylistListAllRes ...

type PmmedEvt

type PmmedEvt struct {
	Text     string  `json:"text"`
	Userid   string  `json:"userid"`
	SenderID string  `json:"senderid"`
	Command  string  `json:"command"`
	Time     float64 `json:"time"`
	Roomobj  struct {
		Chatserver []interface{} `json:"chatserver"`
		Name       string        `json:"name"`
		Created    float64       `json:"created"`
		Shortcut   string        `json:"shortcut"`
		Roomid     string        `json:"roomid"`
		Metadata   struct {
			DjFull               bool          `json:"dj_full"`
			Djs                  []interface{} `json:"djs"`
			ScreenUploadsAllowed bool          `json:"screen_uploads_allowed"`
			CurrentSong          interface{}   `json:"current_song"`
			Privacy              string        `json:"privacy"`
			MaxDjs               int           `json:"max_djs"`
			Downvotes            int           `json:"downvotes"`
			Userid               string        `json:"userid"`
			Listeners            int           `json:"listeners"`
			Featured             bool          `json:"featured"`
			Djcount              int           `json:"djcount"`
			CurrentDj            interface{}   `json:"current_dj"`
			Djthreshold          int           `json:"djthreshold"`
			ModeratorID          []string      `json:"moderator_id"`
			Upvotes              int           `json:"upvotes"`
			MaxSize              int           `json:"max_size"`
			Votelog              []interface{} `json:"votelog"`
		} `json:"metadata"`
	} `json:"roomobj"`
}

PmmedEvt ...

type RegisteredEvt

type RegisteredEvt struct {
	Command string `json:"command"`
	Roomid  string `json:"roomid"`
	User    []struct {
		Fanofs  int     `json:"fanofs"`
		Name    string  `json:"name"`
		Created float64 `json:"created"`
		Laptop  string  `json:"laptop"`
		Userid  string  `json:"userid"`
		ACL     float64 `json:"acl"`
		Fans    int     `json:"fans"`
		Points  int     `json:"points"`
		Images  struct {
			Fullfront string `json:"fullfront"`
			Headfront string `json:"headfront"`
		} `json:"images"`
		ID         string  `json:"_id"`
		Avatarid   int     `json:"avatarid"`
		Registered float64 `json:"registered"`
	} `json:"user"`
	Success bool `json:"success"`
}

RegisteredEvt ...

type RemDJEvt

type RemDJEvt struct {
	DjEvt
}

RemDJEvt ...

type RemModeratorEvt

type RemModeratorEvt struct {
	Command string `json:"command"`
	UserID  string `json:"userid"`
	RoomID  string `json:"roomid"`
	Success bool   `json:"success"`
	Modid   string `json:"modid"`
}

RemModeratorEvt ... {"modid": "604173683f4bfc001c3a57d0", "roomid": "604064503f4bfc001be4c57b", "userid": "60b950ebb5178a0013a1e4a0", "command": "rem_moderator", "success": true}

type RoomInfoRes

type RoomInfoRes struct {
	BaseRes
	Room struct {
		Chatserver []interface{} `json:"chatserver"`
		Name       string        `json:"name"`
		Created    float64       `json:"created"`
		Shortcut   string        `json:"shortcut"`
		Roomid     string        `json:"roomid"`
		Metadata   struct {
			Songlog []struct {
				Source   string  `json:"source"`
				Sourceid string  `json:"sourceid"`
				Created  float64 `json:"created"`
				Djid     string  `json:"djid"`
				Score    float64 `json:"score,omitempty"`
				Djname   string  `json:"djname"`
				ID       string  `json:"_id"`
				Metadata struct {
					Coverart string `json:"coverart"`
					Length   int    `json:"length"`
					Artist   string `json:"artist"`
					Song     string `json:"song"`
				} `json:"metadata"`
			} `json:"songlog"`
			DjFull               bool     `json:"dj_full"`
			Djs                  []string `json:"djs"`
			ScreenUploadsAllowed bool     `json:"screen_uploads_allowed"`
			CurrentSong          struct {
				Playlist  string  `json:"playlist"`
				Created   float64 `json:"created"`
				Sourceid  string  `json:"sourceid"`
				Source    string  `json:"source"`
				Djname    string  `json:"djname"`
				Starttime float64 `json:"starttime"`
				ID        string  `json:"_id"`
				Djid      string  `json:"djid"`
				Metadata  struct {
					Coverart string `json:"coverart"`
					Length   int    `json:"length"`
					Artist   string `json:"artist"`
					Song     string `json:"song"`
				} `json:"metadata"`
			} `json:"current_song"`
			Privacy   string `json:"privacy"`
			MaxDjs    int    `json:"max_djs"`
			Downvotes int    `json:"downvotes"`
			Creator   struct {
				Fanofs  int     `json:"fanofs"`
				Name    string  `json:"name"`
				Created float64 `json:"created"`
				Laptop  string  `json:"laptop"`
				Userid  string  `json:"userid"`
				ACL     float64 `json:"acl"`
				Fans    int     `json:"fans"`
				Points  int     `json:"points"`
				Images  struct {
					Fullfront string `json:"fullfront"`
					Headfront string `json:"headfront"`
				} `json:"images"`
				ID         string  `json:"_id"`
				Avatarid   int     `json:"avatarid"`
				Registered float64 `json:"registered"`
			} `json:"creator"`
			Userid            string `json:"userid"`
			Listeners         int    `json:"listeners"`
			StickerPlacements struct {
				Six04130Fb3F4Bfc001809D428 []interface{} `json:"604130fb3f4bfc001809d428"`
			} `json:"sticker_placements"`
			Screens struct {
				Curtain interface{} `json:"curtain"`
				Right   interface{} `json:"right"`
				Left    interface{} `json:"left"`
			} `json:"screens"`
			Featured    bool       `json:"featured"`
			Djcount     int        `json:"djcount"`
			CurrentDj   string     `json:"current_dj"`
			Djthreshold int        `json:"djthreshold"`
			ModeratorID []string   `json:"moderator_id"`
			Upvotes     int        `json:"upvotes"`
			MaxSize     int        `json:"max_size"`
			Votelog     [][]string `json:"votelog"`
		} `json:"metadata"`
	} `json:"room"`
	Djids       []string `json:"djids"`
	Listenerids []string `json:"listenerids"`
	Now         float64  `json:"now"`
	Users       []struct {
		Fanofs  int     `json:"fanofs"`
		Name    string  `json:"name"`
		Created float64 `json:"created"`
		Laptop  string  `json:"laptop"`
		Userid  string  `json:"userid"`
		ACL     float64 `json:"acl"`
		Fans    int     `json:"fans"`
		Points  int     `json:"points"`
		Images  struct {
			Fullfront string `json:"fullfront"`
			Headfront string `json:"headfront"`
		} `json:"images"`
		ID         string  `json:"_id"`
		Avatarid   int     `json:"avatarid"`
		Registered float64 `json:"registered"`
		Bot        bool    `json:"bot"`
	} `json:"users"`
}

RoomInfoRes ...

type RxMsg

type RxMsg struct {
	Msg []byte
}

RxMsg ...

type Search struct {
	Query    string               // Query that was sent to search
	Callback func(rawJson []byte) // Callback to receive search results
}

Search store any searches currently in progress

type SearchRes

type SearchRes struct {
	BaseRes
	List []struct {
		Sourceid string `json:"sourceid"`
		Source   string `json:"source"`
		ID       string `json:"_id"`
		Metadata struct {
			Coverart string `json:"coverart"`
			Length   int    `json:"length"`
			Song     string `json:"song"`
			Artist   string `json:"artist"`
			Adult    bool   `json:"adult"`
		} `json:"metadata"`
	} `json:"docs"`
}

SearchRes ...

type SnaggedEvt

type SnaggedEvt struct {
	Command string `json:"command"`
	UserID  string `json:"userid"`
	RoomID  string `json:"roomid"`
}

SnaggedEvt ...

type SpeakEvt

type SpeakEvt struct {
	Command string
	UserID  string
	Name    string
	Text    string
}

SpeakEvt struct received when someone speak in the public chat

type TxMsg

type TxMsg struct {
	Payload  H
	Callback func([]byte)
}

TxMsg ...

type UnackMsg

type UnackMsg struct {
	MsgID    int                  // Message ID sent to socket server
	Payload  H                    // Payload that we sent to socket server
	Callback func(rawJson []byte) // Callback to receive answer from socket server
}

UnackMsg store information about a message we sent that is not ack yet

type UpdateVotesEvt

type UpdateVotesEvt struct {
	CurrentSong struct {
		ID        string  `json:"_id"`
		Starttime float64 `json:"starttime"`
	} `json:"current_song"`
	Roomid  string `json:"roomid"`
	Command string `json:"command"`
	Success bool   `json:"success"`
	Room    struct {
		Metadata struct {
			Upvotes   int        `json:"upvotes"`
			Downvotes int        `json:"downvotes"`
			Listeners int        `json:"listeners"`
			Votelog   [][]string `json:"votelog"`
		} `json:"metadata"`
	} `json:"room"`
}

UpdateVotesEvt ... Note: the userid is provided only if the user vote up, or later changes their mind and vote down.

type UserAvailableAvatarsRes

type UserAvailableAvatarsRes struct {
	BaseRes
	Avatars []struct {
		Avatarids []int   `json:"avatarids"`
		Min       int     `json:"min"`
		ACL       float64 `json:"acl,omitempty"`
		Pro       []struct {
			Colwidth  int    `json:"colwidth"`
			Name      string `json:"name"`
			Avatarids []int  `json:"avatarids"`
		} `json:"pro,omitempty"`
	} `json:"avatars"`
}

UserAvailableAvatarsRes ...

type UserInfoRes

type UserInfoRes struct {
	BaseRes
	Fanofs          int     `json:"fanofs"`
	Name            string  `json:"name"`
	Created         float64 `json:"created"`
	UnverifiedEmail string  `json:"unverified_email"`
	Laptop          string  `json:"laptop"`
	Userid          string  `json:"userid"`
	ACL             float64 `json:"acl"`
	Email           string  `json:"email"`
	Fans            int     `json:"fans"`
	Points          int     `json:"points"`
	Images          struct {
		Fullfront string `json:"fullfront"`
		Headfront string `json:"headfront"`
	} `json:"images"`
	ID            string  `json:"_id"`
	Avatarid      int     `json:"avatarid"`
	Registered    float64 `json:"registered"`
	HasTtPassword bool    `json:"has_tt_password"`
}

UserInfoRes ...

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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