Documentation
¶
Index ¶
- Constants
- Variables
- func AbortGame(gameid string) error
- func AcceptChallenge(gameid string) error
- func AuthUser() (string, error)
- func CreateAiChallenge(challenge CreateChallengeType) (error, string)
- func CreateChallenge(challenge CreateChallengeType) (error, string)
- func CreateSeek(challenge CreateChallengeType) error
- func GetChallenges() ([]ChallengeInfo, []ChallengeInfo, error)
- func GetEmail() (string, error)
- func GetFriends() ([]string, error)
- func GetUsername() (string, error)
- func HandleDraw(gameid string, accept bool) error
- func HandleTakeback(gameid string, accept bool) error
- func MakeMove(gameid string, move string) error
- func PerformOAuth() (string, error)
- func ResignGame(gameid string) error
- func StreamBoardState(EventChannel chan<- BoardEvent, StreamError chan<- error, game string)
- func StreamEvent(EventChannel chan<- StreamEventType, got_token chan struct{}) error
- func TimeCheck()
- type BoardEvent
- type BoardEventEnum
- type ChallengeInfo
- type CreateChallengeType
- type OngoingGameInfo
- type StreamBoardChat
- type StreamBoardGameFull
- type StreamBoardGameState
- type StreamBoardResign
- type StreamEventChallenge
- type StreamEventGame
- type StreamEventType
- type UserConfig
Constants ¶
Variables ¶
View Source
var ( UserInfo = UserConfig{ApiToken: "", TokenCreationDate: time.Now(), TokenExpirationDate: time.Now().AddDate(1, 0, 0)} StreamEventStarted bool = false Online bool = false Scopes = []string{ "preference:read", "preference:write", "email:read", "challenge:read", "challenge:write", "challenge:bulk", "study:read", "study:write", "puzzle:read", "follow:read", "follow:write", "msg:write", "bot:play", "board:play", } )
Functions ¶
func AcceptChallenge ¶
func CreateAiChallenge ¶
func CreateAiChallenge(challenge CreateChallengeType) (error, string)
func CreateChallenge ¶
func CreateChallenge(challenge CreateChallengeType) (error, string)
create a challenge against a specific user or get the url (POST)
func CreateSeek ¶
func CreateSeek(challenge CreateChallengeType) error
func GetChallenges ¶
func GetChallenges() ([]ChallengeInfo, []ChallengeInfo, error)
func GetFriends ¶
application/x-ndjson list of friends(and their online/offline status), to be displayed on challenge screen
func HandleDraw ¶
func HandleTakeback ¶
func PerformOAuth ¶
func ResignGame ¶
func StreamBoardState ¶
func StreamBoardState(EventChannel chan<- BoardEvent, StreamError chan<- error, game string)
https://lichess.org/api/board/game/stream/{gameId} after initializing a game, this function streams the the state of the board of the game
func StreamEvent ¶
func StreamEvent(EventChannel chan<- StreamEventType, got_token chan struct{}) error
starts event stream for a user after login
Types ¶
type BoardEvent ¶
type BoardEvent struct { Type BoardEventEnum Full StreamBoardGameFull State StreamBoardGameState Chat StreamBoardChat Resign StreamBoardResign }
type BoardEventEnum ¶
type BoardEventEnum int
const ( GameFull BoardEventEnum = iota GameState ChatLine ChatLineSpectator GameStateResign EOF )
type ChallengeInfo ¶
type ChallengeInfo struct { ID string `json:"id"` URL string `json:"url"` Color string `json:"color"` Direction string `json:"direction"` TimeControl struct { Increment int `json:"increment"` Limit int `json:"limit"` Show string `json:"show"` Type string `json:"type"` } `json:"timeControl"` Variant struct { Key string `json:"key"` Name string `json:"name"` Short string `json:"short"` } `json:"variant"` Challenger struct { ID string `json:"id"` Name string `json:"name"` Online bool `json:"online"` Provisional bool `json:"provisional"` Rating int `json:"rating"` Title string `json:"title"` } `json:"challenger"` DestUser struct { ID string `json:"id"` Name string `json:"name"` Online bool `json:"online"` Provisional bool `json:"provisional"` Rating int `json:"rating"` Title string `json:"title"` } `json:"destUser"` Perf struct { Icon string `json:"icon"` Name string `json:"name"` } `json:"perf"` Rated bool `json:"rated"` Speed string `json:"speed"` Status string `json:"status"` }
type CreateChallengeType ¶
type OngoingGameInfo ¶
type OngoingGameInfo struct { GameID string `json:"gameId"` FullID string `json:"fullId"` Color string `json:"color"` Fen string `json:"fen"` HasMoved bool `json:"hasMoved"` IsMyTurn bool `json:"isMyTurn"` LastMove string `json:"lastMove"` Opponent struct { ID string `json:"id"` Rating int `json:"rating"` Username string `json:"username"` } `json:"opponent"` Perf string `json:"perf"` Rated bool `json:"rated"` SecondsLeft int `json:"secondsLeft"` Source string `json:"source"` Speed string `json:"speed"` Variant struct { Key string `json:"key"` Name string `json:"name"` } `json:"variant"` }
https://lichess.org/api#operation/apiAccountPlaying
func GetOngoingGames ¶
func GetOngoingGames() ([]OngoingGameInfo, error)
type StreamBoardChat ¶
type StreamBoardGameFull ¶
type StreamBoardGameFull struct { Type string `json:"type"` ID string `json:"id"` Rated bool `json:"rated"` Variant struct { Key string `json:"key"` Name string `json:"name"` Short string `json:"short"` } `json:"variant"` Clock struct { Initial int `json:"initial"` Increment int `json:"increment"` } `json:"clock"` Speed string `json:"speed"` Perf struct { Name string `json:"name"` } `json:"perf"` CreatedAt int64 `json:"createdAt"` White struct { ID string `json:"id"` Name string `json:"name"` Provisional bool `json:"provisional"` Rating int `json:"rating"` Title string `json:"title"` } `json:"white"` Black struct { ID string `json:"id"` Name string `json:"name"` Rating int `json:"rating"` Title interface{} `json:"title"` } `json:"black"` InitialFen string `json:"initialFen"` State struct { Type string `json:"type"` Moves string `json:"moves"` Wtime int `json:"wtime"` Btime int `json:"btime"` Winc int `json:"winc"` Binc int `json:"binc"` Status string `json:"status"` } `json:"state"` }
type StreamBoardGameState ¶
type StreamBoardGameState struct { Type string `json:"type"` Moves string `json:"moves"` Wtime int `json:"wtime"` Btime int `json:"btime"` Winc int `json:"winc"` Binc int `json:"binc"` Status string `json:"status"` Winner string `json:"winner"` Wdraw bool `json:"wdraw"` Bdraw bool `json:"bdraw"` Wtakeback bool `json:"wtakeback"` Btakeback bool `json:"btakeback"` }
type StreamBoardResign ¶
type StreamEventChallenge ¶
type StreamEventChallenge struct { Type string `json:"type"` Challenge struct { ID string `json:"id"` URL string `json:"url"` Status string `json:"status"` Compat struct { Bot bool `json:"bot"` Board bool `json:"board"` } `json:"compat"` Challenger struct { ID string `json:"id"` Name string `json:"name"` Title string `json:"title"` Rating int `json:"rating"` Patron bool `json:"patron"` Online bool `json:"online"` Lag int `json:"lag"` } `json:"challenger"` DestUser struct { ID string `json:"id"` Name string `json:"name"` Title interface{} `json:"title"` Rating int `json:"rating"` Provisional bool `json:"provisional"` Online bool `json:"online"` Lag int `json:"lag"` } `json:"destUser"` Variant struct { Key string `json:"key"` Name string `json:"name"` Short string `json:"short"` } `json:"variant"` Rated bool `json:"rated"` TimeControl struct { Type string `json:"type"` Limit int `json:"limit"` Increment int `json:"increment"` Show string `json:"show"` } `json:"timeControl"` Color string `json:"color"` Speed string `json:"speed"` Perf struct { Icon string `json:"icon"` Name string `json:"name"` } `json:"perf"` } `json:"challenge"` }
type StreamEventGame ¶
type StreamEventGame struct { Type string `json:"type"` Game struct { GameID string `json:"gameId"` FullID string `json:"fullId"` Color string `json:"color"` Fen string `json:"fen"` HasMoved bool `json:"hasMoved"` IsMyTurn bool `json:"isMyTurn"` LastMove string `json:"lastMove"` Opponent struct { ID string `json:"id"` Rating int `json:"rating"` Username string `json:"username"` } `json:"opponent"` Perf string `json:"perf"` Rated bool `json:"rated"` SecondsLeft int `json:"secondsLeft"` Source string `json:"source"` Speed string `json:"speed"` Variant struct { Key string `json:"key"` Name string `json:"name"` } `json:"variant"` Compat struct { Bot bool `json:"bot"` Board bool `json:"board"` } `json:"compat"` } `json:"game"` }
type StreamEventType ¶
Click to show internal directories.
Click to hide internal directories.