Forked an application for the first time

I have been using a bot designed by someone else to play my extra Splinterlands cards. The application the bot uses had some issues upon first use and since then I have made a few changes to the scripts to make it run better on my virtual machines. And figured it would be a good idea to make my own fork of the application.

My first change was made to the package.json file. When I tried to run the application for the first time I got a package conflict error, upon opening up the file in a text editor I saw the following near the bottom.

`<<<<<<< HEAD
"puppeteer": "^2.1.1"
=======
"puppeteer": "^2.1.1",
"minimist": ">=1.2.3"
>>>>>>> ad56a3a8c469f49ccb88a7656245efe54ae43f9e`

I believe having two puppeteer entries was causing this error, so I removed one and the other invalid json in that file. Below is now how the package.json file looks. Puppeteer uses Chromium to launch an automated session in the browser, it can reload pages, enter login info and click through the menus.

`{
"name": "Solo's fork of splinter-scraper",
"version": "1.0.1",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "node index.js"
},
"author": "",
"license": "ISC",
"dependencies": {
"dimas-kmeans": "^1.0.3",
"dotenv": "^8.2.0",
"hierarchical-clustering": "^1.1.0",
"minimist": ">=0.2.1",
"node-cron": "^2.0.3",
"node-fetch": "^2.6.0",
"pg": "^8.0.3",
"puppeteer": "^2.1.1"
  } 
}`

Now when I run the script it no longer gets a package conflict, and I added my name to the fork along with changing the version to 1.0.1

I made the readme more clear, and added how you can add an .env file to the working directory of the script instead of having to use a global environmental variable file. Since I am running multiple accounts I find this a needed addition.

This is a fork of alfficcadenti's BOT to play the game Splinterlands

Changes have been made to resolve package conflicts, and to resolve script time outs/stops

index.js
run npm start index.js

to start BOT login routine. username and password needs to be specified in the file .env as variable like:                       
ACCOUNT=yourhiveusername PASSWORD=yourhiveprivatepostingkey Create .env text file with the above in the working directory of the             
splinterlands bot and add .env text file to .gitignore

https://peakd.com/hive-13323/@solominer/set-up-my-own-splinterlands-bots

Next up was changes to the index.js file. Right now I am running this bot on a virtual machine, and it does not make use of my graphics card for rendering. So alot of CPU is used instead, this is causing the rendering of the website to take longer. Also seems the popup windows have changed since alfficcadenti's last changes to the script. So I needed to add another set of puppeteer commands to get it working.

    await page.reload();
    await page.waitFor(5000)

Now it does reloads the page three times and waits 5 seconds each time. Without this recently I found the script to stop working. I guess the lands popup is now gone and affecting the script.

As I mentioned my virtual machine runs a little slower than it would on a bare metal machine, I had to adjust the await page.waitfor command. It was set to 3 seconds which I saw the script timing out when my virtual machine could not keep up.

So I added a zero making it wait 30 seconds, more than enough time now for the rendering on the website to catch up. Now it looks like below.

await page.waitFor(30000);

I made some other changes, but found them not working as well as what was set up originally, so I reverted back to what alfficcadenti's defaults were. An example of this was the cron job timing for each battle. It was set to 14 minutes between battles and I found this to be too long. But after battling at 7 minutes for a season I started to get login denies from the Spinterlands.com stating my API calls are too frequent.

cron.schedule('*/15 * * * *', async () => {

I now run 5 of the bots using PM2, a process monitor I have in Ubuntu. I have tried getting this setup to run on my RaspberryPi4 but the ARM build of puppeteer and Chromium seem to have some issues getting it to work. The browser is failing to launch sometimes, so I need to do more research on that to get it running. If I can get it working ill do another fork of alfficcadenti's app just for ARM use.

Still some issues to iron out, such as some battles are aborted due to an error saying there are no teams available for battle. Seems to happen when new rulesets are encountered the and script does not know what to do. It also seems to have issues with calls to herokuapp, stating invalid json sometimes. Maybe the new rulesets need to be added into the script.

Feels good I was able to fix and do some improvements on the script that someone else made. Since it has not been updated since October of last year it was due for a couple changes and glad I was able to do it. Now I have my own github account and forked my first application, with the more and more scripting I do. I can see more forks happening in the future as well.

You can find a link to my fork below:

https://github.com/solominer0/splinterlands-bot

H2
H3
H4
3 columns
2 columns
1 column
16 Comments
Ecency