Utopian spreadsheet management + bot

in #utopian-io6 years ago

Repositories

https://github.com/amosbastian/utopian-spreadsheet
https://github.com/utopian-io/utopian-bot

When Utopian's front end was taken down we needed a way for moderators to keep reviewing contributions and contributors to be able to get rewarded for their hard work. To keep this process running smoothly I created a spreadsheet and a few Python programs that manage the retrieving of contributions, the updating of the worksheets and the upvoting or unvoting of the contributions.

Managing the spreadsheet

The programs for managing the spreadsheet can be found in the first repository. This contains three scripts that are used in conjunction with a crontab to manage everything

The main program. This uses beem to iterate over recent contributions, checks if they are already somewhere in the spreadsheet, and if they are not it, it adds them to it. While doing this it performs some checks, like if the category is valid and/or the user is banned or not. Once everything is confirmed it adds a row containing the URL of the post, the linked repository and its category to the worksheet. It is also used to calculate each moderator's points for the week and saves them to a file, allowing it to be displayed on e.g. https://utopian.rocks/json/2018-05-17.

This checks if contributions in the main worksheet have been reviewed or not. It determines this by checking the moderator, date and score column. If they are all filled the row is deleted and moved to the current week's "reviewed" sheet, so the bot can vote on it for example. While doing this it also calculates the voting percentage the bot should use, and sets the status of the contribution to pending, so the bot also knows it needs to be voted on.

This is used to create a new worksheet and update the name of the main worksheet where unreviewed contributions come in automatically. Moderators get upvoted every Thursday at midnight, hence why each date starts with a Thursday.

Upvoting and unvoting

Once contributions have been reviewed they might need to be upvoted depending on the score. To do this I created two additional programs, one for upvoting and one for unvoting (unfortunately this is sometimes needed), which can be found in the second repository. These scripts are also meant to be used in conjunction with crontab, which is what we do to run them every five minutes.

This basically checks if the bot's voting power is above a certain amount, then sorts the pending contributions by score and picks the one first in the list. It also checks if a contribution has been staff picked, because then the score is disregarded and the contribution automatically receives the highest upvote possible for its category. Once it has selected a contribution it performs some checks, like if the bot has already voted on the contribution or not, then upvotes the contribution, comments on it and updates the spreadsheet.

As I mentioned before sometimes contributions need to be unvoted. To implement this I make it check if any of the contribution's scores have been changed to 0 from something higher than 0 since the last time it was run. If it finds such a contribution, then it is upvoted with a voting % of 0 (which is the same as unvoting), updates the comment under the contribution to reflect this, and updates the sheet so we know it has actually been unvoted.

It was actually pretty nerve-wracking implementing this, because of how huge the consequences could be if something went wrong because of me, haha...

Technology stack

The most important Python packages used are listed below

Roadmap & how to contribute

I don't really have a roadmap for this, as I just keep adding stuff whenever someone asks me to. Hopefully in the future when we have a proper database instead of a spreadsheet (which is actually pretty nice), I can refactor the code to use classes instead of having everything in a separate file (everything was pretty rushed).

Some people have already helped out with little things here and there (shoutout to @crokkon and @mwfiae), so if you want to help out you can simply create a PR/issue like they did or contact me on Discord at Amos#4622.

GitHub Account

https://github.com/amosbastian

Sort:  
  • I like the openness that the code brings to the project.
  • The comments were an enjoyable read.
  • Why documentation with a "k"?

Your contribution has been evaluated according to Utopian rules 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 https://support.utopian.io/.
Chat with us on Discord.
[utopian-moderator]

Thanks! The documentation with a "k" was from a PR, so I blame @mwfiae haha.

It's called german, better get used to it. 😂😂😂

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

Contributing on Utopian
Learn how to contribute on our website or by watching this tutorial on Youtube.

Want to chat? Join us on Discord https://discord.gg/h52nFrV.

Vote for Utopian Witness!

Coin Marketplace

STEEM 0.20
TRX 0.13
JST 0.030
BTC 65092.40
ETH 3470.06
USDT 1.00
SBD 2.50