lichess.org
Donate
Improving code

Easy Heroku Bot: Improving Hyper Bot

Chess botChess engineSoftware DevelopmentLichess
"Don't comment bad code - rewrite it!" ~ Brian Kernighan

EDIT: Recently a few changes have been made making this Blog post slightly Outdated. All info is available on GitHub.

Of late many have been making lichess bots (and by many I mean a lot of people!). Thibault too made a blog on lichess bots (and it is true that making bots if you haven't created the engine is useless, but why not?).

Why not Hyper Bot?

I have seen that many are using hyperbot as it is easy to make and is pretty decently strong, but that repository hasn't been updated in a while (and for some reason has some picture of Putin with some Russian text I don't understand... back to the topic). So I decided to take hyperbot, update it and improve it!

Introducing Easy Heroku Bot

Since the code is not being updated and can be improved in many way I decided to create Easy Heroku Bot. This is basically hyperbot, but it has been improved in many way. Redundant code and unused files were removed and a stronger engines are added.

Well, here's the source code, incase you're interested in what exact code changes I made. It has been uploaded to GitHub as a Public repository: TheYoBots/easyherokubot

What exactly was done?

Stockfish logo
Stockfish Logo

What changes did I really make? If you do have some programming knowledge (especially JavaScript in this case), you will understand what was done by simply looking at this GitHub commit. If you do not know anything about programming or don't want to go through tons of lines of code to find out what was done, here's a gist of everything I've done.

  • Engine Update
    I updated the engine that was being used to Stockfish 14.1 and Fairy-Stockfish 14 (for variants) with NNUE.
    To enable these latest versions of Stockfish, set USE_STOCKFISH14 to true in your Config Vars.
    Note: The USE_NNUE option is now disabled and doesn't exist, but by default NNUE is used in all variants.
  • Remove Lc0 support
    I removed Lc0 support as the code was barely working, was extremely slow and continuously resulted in crashes. The repository will not run Lc0 anymore, but it will run Stockfish extremely smoothly.
  • Remove unused files
    Deleted all useless files that were in that repository, but were never used for heroku deployment. I saw that there was clearly no need for these many files, so I removed them. It was also extremely hard to understand the code when most files were not needed but were still in the repository.

These are the changes. To run this bot simply follow the same instructions followed for running hyperbot just for this repository.

Warning about Apps that expose Token

Warning
Don't use any Oauth App that exposes your API Access Token!

I went through the easychess and hypereasy code and found out that when a user logs in through these apps, the users API Access Token gets exposed and gets printed in the console logs. I suggest you don't use such apps as Lichess mentions never to share your API Access Token to anyone. Here's proof that these oauth apps expose API Access Token by printing it in the console logs:
Proof in code that easychess exposes API Access Token
Proof in code that hypereasy exposes API Access Token

Upgrading to a Bot Account

Bot icon
Lichess Bot icon

If you want to upgrade to a bot account without your API Access Token getting exposed use any Oauth App that Upgrades your account without exposing your API Access Token or directly use Lichess' Bot API.

Incase you are searching for an Oauth App that Upgrades a normal account to a Bot account, I've made one. It does nothing other that upgrade an account to a bot account. Check it out: lichess-bot-upgrader

It's simple and bland, with very less code. To upgrade an account to a Bot account using this Oauth App, simply Login with Lichess, Authorize and then Click on 'Upgrade to a bot account' and If you see the message {"ok": true} your account should be upgraded to a Bot account. (This Upgrade is irreversible)

If you want to see the source code to find out whether it actually doesn't expose the API Acces Token, check it out here: TheYoBots/BotUpgrader.

I hope you enjoyed this Blog and Thanks for Reading!