SteemFlagRewards bot: Dedicated configuration file and code restructuring

10개월 전



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, 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.

GitHub Account

Authors get paid when people like you upvote their post.
If you enjoyed what you read here, create your account today and start earning FREE STEEM!
Sort Order:  trending

Nice cleanup, @crokkon.

Looks like it also helps to make it easier to contribute to the repository.

Small note:

Regarding this type of check, I find it more convenient to use groups for the permissions. (Ex: creating a editors group in the discord, and check for the user has that role.)

Since everyone do that in strict ID checks, wondering is there a specific reason for that? :)

Your contribution has been evaluated according to Utopian policies and guidelines, as well as a predefined set of questions pertaining to the category.

To view those questions and the relevant answers related to your post, click here.

Need help? Write a ticket on
Chat with us on Discord.


Thanks for the review, Emre! The main reason for using discord user IDs here is that is was like this before and I didn't want to introduce conceptual changes during this refactoring phase. Using a dedicated discord role is indeed a good idea here - thanks! Roles vs. ID checks is a bit a trade-off between where the setup and config is done and stored. User IDs allow for a minimal discord setup, any bare server can be used for testing. It may need adjustments in the bot config but all config is then under version control. Testing with roles may need fewer bot config changes but requires the discord server to be prepared accordingly - > out of git. Members wouldn't be revealed with roles, if this is considered sensitive information, though...


Thank you for your review, @emrebeyler! Keep up the good work!

Wow thanks Crokkon. Your help has made a big difference. I am glad we have you on our team.
We are all learning so much from your skills.
We are super excited for the future of our project
Thanks for the mention, Ive been so busy I just noticed it.

Thank you for helping us! Moving those to a config file is definitely a good move.

Thank goodness we have you as one of the devs working on the bot.


I second this comment.



Hi, how can I join and flag spam posts?


Hi @jmehta, join the SFR Discord server:
There is detailed information on how SFR works and the people there will be glad to help you getting started!

Hi @crokkon!

Your post was upvoted by @steem-ua, new Steem dApp, using UserAuthority for algorithmic post curation!
Your post is eligible for our upvote, thanks to our collaboration with @utopian-io!
Feel free to join our @steem-ua Discord server

Hello, as a member of @steemdunk you have received a free courtesy boost! Steemdunk is an automated curation platform that is easy to use and built for the community. Join us at

Upvote this comment to support the bot and increase your future rewards!

Hey, @crokkon!

Thanks for contributing on Utopian.
We’re already looking forward to your next contribution!

Get higher incentives and support!
Simply set as a 5% (or higher) payout beneficiary on your contribution post (via SteemPlus or Steeditor).

Want to chat? Join us on Discord

Vote for Utopian Witness!