a twitch bot that gives you the ability to play against your twitch chat on lichess.
You (the streamer) will be playing on your Lichess account while Chat should be playing on another one.
Chat is going to vote for moves, the most voted move is played by the bot.
First you need to install some stuff to make it work:
-
Download & Install nodejs on your computer (google that).
-
After doing that, now open cmd and install:
-
install twitch api library
npm install tmi.js
-
install axios request library
npm install axios
-
install express web framework library
npm install express
-
install socket.io websockets library
npm install socket.io
-
-
Now we need to set some variables:
-
Twitch account that the bot will use (you can use your main one).
- to give the bot control of your account we need a OAuth token, that you can get from here
(DO NOT SHARE THIS TOKEN)
-
Lichess account that the chat will play on (i recommend that you create a new account)
- we need a personal token to give the bot permission to use the Lichess account, get the token from here
- create a new personal token and these are the permissions you should give it:
- Read preferences
- Create, accept, decline challenges
- Play games with the board API
-
Go to the
ChatPlaysChess.js
file and replace:YOUR_LICHESS_TOKEN
with your Lichess tokenoauth:PUT_YOUR_AUTH_KEY_HERE
with your Twitch OAuth token, make sure to include theoauth:
-
-
We need to tell the bot which channel it should join. to do that:
- search for a variable named
channelsToJoin
and replace its value with the desired twitch channel
- search for a variable named
-
We need to tell the bot who can use the commands (should be you and/or the mods). to do that:
- search for an array named
allowedToUseCommands
and add twitch usernames of the people who can use the commands. these people are going to be able to create a game or resign it, you should put your twitch username here and your mods, no more, unless you want chaos.
- search for an array named
Now you can run it by simply typing node ChatPlaysChess.js
in cmd
or however you want.
if everything works fine, you'll see Bot is Connected
in your chat, if you just created the lichess account, you'll probably get a token error, in that case just give it some time. any other question you can whisper me on Twitch or DM me on discord xSplasher#3998 .
in chat type !challon
then !challengeme LichessUsernameToBeChallenged
the challenged player has 10-13 seconds to accept the challenge.
to vote for moves type a1a8
or c1f4
in chat, squares only.
-
e2e4
is how you vote, want to move the knight on g1 to f3 ? typeg1f3
castle king side as white ?e1g1
- accessible by chat only when it's chat's turn to play
-
!challon
Make Challenge On- after executing this everybody in chat can send a challenge
-
!challoff
Make Challenge Off -
!challengeme LichessUsernameToBeChallenged
Make chat play a casual game against someone on Lichess- requires executing
!challon
to work - the challenged player has 10-13 seconds to accept the challenge
- if you want to change the game settings, like time control etc, check the function named
Challenge
:- Clock: change
clock
variable to the desired value in seconds. - Color: change
playercolor
variable towhite
black
orrandom
- Increment: change
icr
variable to the desired value in seconds. - Game Type: change
rated
variable totrue
to play a Rated game, orfalse
for a Casual one (IMPORTANT: i do NOT recommand you to play a rated game, your account could be banned, please keep this variable alwaysfalse
unless you're willing to take the risk of getting banned).
- Clock: change
- requires executing
-
!seek
Make chat play a casual game against a random person on Lichess (Not heavily tested)- if you want to change the game settings, like time control etc, check the function named
SeekGame
:- Same as Challenge function except; Clock: change
timeinMinutes
variable to the desired value in minutes.
- Same as Challenge function except; Clock: change
- if you want to change the game settings, like time control etc, check the function named
-
!resign
Resign the game currently playing -
!cont
to Continue a game already playing (if you stopped the bot in the middle of the game and want to continue) -
!move e1e2
Forces a move to be played. -
!closepoll
immediately closes the poll and plays the most voted move. -
!jail TwitchUserName
after executing this command, the bot will start rejectingTwitchUserName
's votes. (if somebody is trolling, use this command to jail them) -
!free TwitchUserName
the bot will start acceptingTwitchUserName
's votes.
after you start the bot, open obs in your 'Sources' add a 'Browser' and put http://localhost:7777/
as the URL.
make sure index.html
is in the same directory as ChatPlaysChess.js
file.
it will start showing moves when it's chat's turn to move.