dolegi / lichess-bot Goto Github PK
View Code? Open in Web Editor NEWLichess bot api bridge
License: GNU Affero General Public License v3.0
Lichess bot api bridge
License: GNU Affero General Public License v3.0
Sometimes Lichess produces HTTP 400, although the second example refers to an unfinished game where Lichess rejected a legal move. It would be good to output the error message produced by Lichess:
Nov 30 14:43:51 vps178028 lichess-bot[25071]: Accepting challenge {mGriu2II created {leelapi LeelaPi BOT 1872 false true 4} {godelescherbot GodelEscherBot BOT 2077 false true 0} {standard} false rapid random}
Nov 30 14:45:05 vps178028 lichess-bot[25071]: REQUEST bot/game/mGriu2II/move/c7c5
Nov 30 14:45:05 vps178028 lichess-bot[25071]: Response 400 POST bot/game/mGriu2II/move/c7c5
Nov 30 14:55:36 vps178028 lichess-bot[25071]: Accepting challenge {hVOzc2Xr created {leelapi LeelaPi BOT 1872 false true 4} {godelescherbot GodelEscherBot BOT 2077 false true 0} {standard} false rapid random}
Nov 30 14:55:41 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/e2e4
Nov 30 14:55:52 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/g1f3
Nov 30 14:56:05 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/f1b5
Nov 30 14:57:10 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/d2d3
Nov 30 14:57:19 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/b5c6
Nov 30 14:57:41 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/e1g1
Nov 30 14:58:21 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/b1d2
Nov 30 14:58:32 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/d2c4
Nov 30 15:00:07 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/h2h3
Nov 30 15:00:51 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/f3h4
Nov 30 15:02:36 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/a2a4
Nov 30 15:03:10 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/c1e3
Nov 30 15:04:01 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/h4f5
Nov 30 15:05:44 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/b2b3
Nov 30 15:06:47 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/g1h2
Nov 30 15:07:55 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/h3h4
Nov 30 15:08:55 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/g2g4
Nov 30 15:09:48 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/f1g1
Nov 30 15:10:26 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/h4h5
Nov 30 15:11:06 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/c4d2
Nov 30 15:11:47 vps178028 lichess-bot[25071]: REQUEST bot/game/hVOzc2Xr/move/f5h4
Nov 30 15:11:47 vps178028 lichess-bot[25071]: Response 400 POST bot/game/hVOzc2Xr/move/f5h4
PS G:\project\lichess> go version
go version go1.17.3 windows/amd64
PS G:\project\lichess> go get github.com/dolegi/lichess-bot
go get: installing executables with 'go get' in module mode is deprecated.
Use 'go install pkg@version' instead.
For more information, see https://golang.org/doc/go-get-install-deprecation
or run 'go help get' or 'go help install'.
# github.com/dolegi/lichess-bot
C:\Users\ZerQAQ\go\pkg\mod\github.com\dolegi\[email protected]\stream_game.go:47:30: unknown field 'Type' in struct literal of type uci.NewGameOpts
go install does not work too
It appears a segmentation fault occurred... I didn't know that was possible in Go https://lichess.org/Gig0kNFp/black#17 :
May 31 04:49:45 vps178028 lichess-bot[16040]: Accepting challenge {HRGAQ7S6 created {chijss Chijss 2061 false true 2} {godelescherbot GodelEscherBot BOT 2474 false true 0} {atomic} true blitz white}
May 31 04:49:48 vps178028 lichess-bot[16040]: {gameFull Gig0kNFp true {atomic} {180000 2000} blitz startpos {gameState 180000 180000 2000 2000} {chijss} {godelescherbot} 0 0 0 0}
May 31 04:49:52 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 180000 180000 2000 2000}
May 31 04:50:01 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/f7f6
May 31 04:50:01 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 f7f6 180000 180000 2000 2000}
May 31 04:50:05 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 f7f6 e2e3 178190 180000 2000 2000}
May 31 04:50:07 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/e7e6
May 31 04:50:07 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 178190 179480 2000 2000}
May 31 04:50:27 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 160270 179480 2000 2000}
May 31 04:50:31 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/c7c6
May 31 04:50:32 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 160260 177340 2000 2000}
May 31 04:50:39 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 155060 177340 2000 2000}
May 31 04:50:42 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/c6b5
May 31 04:50:42 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 155060 176020 2000 2000}
May 31 04:50:45 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 154480 176020 2000 2000}
May 31 04:50:47 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/g7g6
May 31 04:50:48 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 g7g6 154470 175130 2000 2000}
May 31 04:50:48 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 g7g6 h5b5 156480 175120 2000 2000}
May 31 04:50:56 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/b8c6
May 31 04:50:57 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 g7g6 h5b5 b8c6 156470 168570 2000 2000}
May 31 04:50:57 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 g7g6 h5b5 b8c6 b5b6 158480 168560 2000 2000}
May 31 04:50:59 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/a7b6
May 31 04:50:59 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 g7g6 h5b5 b8c6 b5b6 a7b6 158470 168100 2000 2000}
May 31 04:51:01 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 g7g6 h5b5 b8c6 b5b6 a7b6 f1b5 159170 168090 2000 2000}
May 31 04:51:04 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/e8f7
May 31 04:51:04 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 g7g6 h5b5 b8c6 b5b6 a7b6 f1b5 e8f7 159160 166410 2000 2000}
May 31 04:51:06 vps178028 lichess-bot[16040]: {gameState false {} {0 0} { 0 0 0 0} {} {} g1f3 f7f6 e2e3 e7e6 f3d4 c7c6 d4b5 c6b5 d1h5 g7g6 h5b5 b8c6 b5b6 a7b6 f1b5 e8f7 b5d7 159710 166400 2000 2000}
May 31 04:51:15 vps178028 lichess-bot[16040]: REQUEST bot/game/Gig0kNFp/move/a8a2
May 31 04:51:15 vps178028 lichess-bot[16040]: Failed request POST bot/game/Gig0kNFp/move/a8a2 Post https://lichess.org/api/bot/game/Gig0kNFp/move/a8a2: dial tcp: lookup lichess.org on 127.0.0.53:53: dial udp 127.0.0.53:53: socket: too many open files
May 31 04:54:03 vps178028 lichess-bot[16040]: Accepting challenge {Gig0kNFp created {chijss Chijss 2072 false true 4} {godelescherbot GodelEscherBot BOT 2474 false true 0} {atomic} true blitz black}
May 31 04:54:06 vps178028 lichess-bot[16040]: Failed request GET bot/game/stream/DfI0p9kT Get https://lichess.org/api/bot/game/stream/DfI0p9kT: dial tcp: lookup lichess.org on 127.0.0.53:53: dial udp 127.0.0.53:53: socket: too many open files
May 31 04:54:06 vps178028 lichess-bot[16040]: panic: runtime error: invalid memory address or nil pointer dereference
May 31 04:54:06 vps178028 lichess-bot[16040]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x48 pc=0x68a7b0]
May 31 04:54:06 vps178028 lichess-bot[16040]: goroutine 1 [running]:
May 31 04:54:06 vps178028 lichess-bot[16040]: main.streamGame(0xc0032c5210, 0x8, 0xc0000523c0)
May 31 04:54:06 vps178028 lichess-bot[16040]: /home/turing/lichess-bot/stream_game.go:46 +0xa0
May 31 04:54:06 vps178028 lichess-bot[16040]: main.handleEvent(0xc00352c000, 0xc0000523c0)
May 31 04:54:06 vps178028 lichess-bot[16040]: /home/turing/lichess-bot/stream_event.go:75 +0x103
May 31 04:54:06 vps178028 lichess-bot[16040]: main.streamEvent(0xc0000523c0)
May 31 04:54:06 vps178028 lichess-bot[16040]: /home/turing/lichess-bot/stream_event.go:59 +0x18c
May 31 04:54:06 vps178028 lichess-bot[16040]: main.main()
May 31 04:54:06 vps178028 lichess-bot[16040]: /home/turing/lichess-bot/main.go:106 +0x591
Similar to lichess-bot-devs/lichess-bot#584 , automatically reconnect the client if Lichess restarts.
I attempted to play a chess960 game against my bot (Stockfish supports every Lichess variant), and I don't know what went wrong:
https://lichess.org/Bg5bUFlW
Apparently if an opponent's lag or online status changes, there are two challenge events. This wrapper doesn't care about the opponent's lag or online status.
Aug 04 06:21:27 vps178028 lichess-bot[16108]: Accepting challenge {DVKEO0nx created {szachowy_kox Szachowy_Kox 1943 false true 3} {godelescherbot GodelEscherBot BOT 2456 false true 0} {racingKings} false bullet black}
Aug 04 06:21:33 vps178028 lichess-bot[16108]: Declining challenge {DVKEO0nx created {szachowy_kox Szachowy_Kox 1943 false true 4} {godelescherbot GodelEscherBot BOT 2456 false true 0} {racingKings} false bullet black}
Perhaps the first step of this function should be to check whether lichess-bot
thinks it has a game in progress whose ID is the same as the challenge ID:
Lines 64 to 73 in 97af669
There's a new field in the API: https://lichess.org/api#operation/challengeDecline
Maybe lichess-bot could make use of it.
Copied from lichess-bot-devs/lichess-bot#247
BOT opponents might take more than an hour on their first move:
https://lichess.org/wCezm8ck/black
Rather than leaving the game hanging forever, maybe after an hour abort the game.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.