The Magic Frog in French (Development Update #4) by helo

Repository:

https://github.com/mktcode/the-magic-frog

image.png

New Features

  • Testing options in an immutable world
  • Formatting output for winning post
  • Curators by Story for proper reward
  • dotenv, making our lifes easier
  • eslint is the new master in town

Testing the bot for its output

The bot script that votes, makes daily posts and in the end distributes the SBD after selecting a winner is key in the magic frog project. To be able to repetitively test the output when the stories end, I needed a way to prevent actions on the blockchain from occurring. I then proceeded to create a new environment variable BOT_PROD=false and set it to false when I'm developing.

I proceeded by encompassing all blockchain actions within an if statement:
image.png

Formatting output for winning post

Knowing that the French story was coming to an end, I prepared the bot to produce the winning log and SBD distributions in a markdown way.

Some adaptations were needed, for example we did not need percentage to be push on the stack before, now we do.
image.png

It does not look like much in the shell, but wait to see what happens on Steemit or Busy!
image.png

Checkout the results of the winning announcement post for a reveal of the efforts I put in.

Curators by Story for proper reward

Curator calculations are simple for the Hall-of-fame on the portal, but for rewarding curators when the story ends, we needed to pass the story number we want the curators from. That meant to extend the API and pass a new parameter from the bot.

From the-magic-story-machine side: image.png

From the-magic-link API side either from all stories or just a specific one: image.png

dotenv, making our lifes easier

I implemented dotenv in all 3 repositories, it's one thing less to remember to source the environment variables before running the scripts and a more standardised way that will simplify development as we bring more people on board. (A Portuguese frog coming soon! @sapo-magico)

To get this running is a 2 step process to get your process.env.VARIABLES automagically loaded from a .env file.

  • run this command to install: npm i dotenv --save
  • insert this at the top of you main js file: require('dotenv').config();

eslint and the new master in town

Following a suggestion from @gregory.latinier on a development article from master @mkt, I decided to implement eslint on all 3 repositories of the project. A lot of changes ensued.

To get started after the installation using npm install eslint --save-dev, you need to run the configuration wizard ./node_modules/.bin/eslint --init then supplement the configuration file with you project specific requirements.

image.png

I added a new script command so that we can easily lint the code by doing this: npm run lint

There was a lot of refactoring to stop eslint from complaining issuing errors. Just like below: [no-loop-func] [no-prototype-builtins] [prefer-const]
image.png

A few more rules made me switch things around. [prefer-destructuring] for the account variable and [radix] add the base 10 as an extra parameter of parseInt, who knew that was needed? :

For the-magic-frog I had to ignore a few directories since they are generated on the fly and should not be linted.

Previous contributions in this series

How to contribute

Simple! 1. fork, 2. modify, 3. submit a pull request to the official repository.

Repositories

Proof of work

GitHub Account

https://github.com/gluneau

To see the changes in action... PARTICIPATE!

Visit:
the-magic-frog.com or
fr.the-magic-frog.com

H2
H3
H4
Upload from PC
Video gallery
3 columns
2 columns
1 column
10 Comments