The @steemflagrewards project rewards Steem abuse fighters for using their stake to flag abusive content based on a list of predefined categories. For an introduction to the @steemflagrewards project and the inner workings, see @iamstan's post on Antiabuse Contribution for October.
The votes given out by @steemflagrewards are cast with a bot. This contribution describes changes to the bot code to improve the scalability and maintainability of the project. The changes were proposed via PR #10 and merged to master by @anthonyadavisii in 1b008e8.
Changes related to the creation and extension of a central configuration file
- Move configuration parameters into a dedicated file, commit b9d7df4:
Previously, several configuration options like Discord channel and user IDs, links, names, etc. were integrated into the bot code at the place where it was used. This imposed several limitations, especially when running the code in a test environment, because several parts of the bot code had to be touched to make this work without any functional changes. By moving these parameters into
sfr_config.py, the exact same bot code can be used with an adjusted config file. Code changes to the bot can now easily be committed without having to revert local/test environment settings. The list of abuse categories could be reduced from a list and a dict to only a dict, reducing redundant information.
- Move Discord invite link to the configuration file, commit 32279b5:
Discord invite links were previously directly inserted into the SFR post and comment templates. A changing Discord link meant to adjust several places in the code, and eventually different and expired invites made it into the previous code. With the invite link in the config file, only a single location has to be changed to adjust all occurrences of the link in any SFR posts or comments.
- Move the list of witnesses and supporters to the configuration file, commit bec574b:
The list of witnesses that are mentioned in the report posts, as well as SteemConnect delegation links and a list of supporting users were previously hard-coded into the bot code. By moving these lists into the configuration file, the list of witnesses and users can easily be adjusted and the corresponding SteemConnect links are generated automatically. By moving the post body assembly into a dedicated function, it can be tested standalone without actually making a post and in different configurations.
Restructuring and Maintenance
- Moving the generation of the approval comment body into a function that can be called from different places in the code enables to test this part separately and reduces redundancy, commit 96f2360.
- Updating beem requirements for HF20, commit 8adf763.
- Removing unused imports, commit 14a5bc8.
- Some first PEP8 adjustments, commit 86d698a. The remaining code parts will be adjusted accordingly when touched with future changes/restructurings.