Steemit Giveaway/Lottery Script

in #steemit7 years ago (edited)

1.png


I had wrote a quick python script to make giveaways easier on Steemit. I see that many people are doing lotteries and giveaways here so this could be very useful to many people.

I had a giveaway recently, where people had to guess a number between 1-10,000:

The problem is that only a few people participated and the game had probability 0.01% of guessing it, with all commenters 0.65%. Well that is a problem, because then I had to give out the prize to the person who had the nearest guess, but how do I find that?

The winner number was 4661. So if somebody had guessed this, you would just press CTRL+F in the browser, and search for this number, and the first person who guessed this, would win the lottery.

But what if the nearest guess is 4600? Would you go through all numbers like 100 point distance on both sides of the axis, so you would have to go and search for: 4662,4660,4663,4659,4664,4658,..... and so on.

This is very unfeasible especially if you have like 100-200 participants, going through all their "near guesses" is practically impossible. So that is why I wrote this quick python script to do it for you.




The Script

The script is in python and doesn’t need any other dependency only the re package which is a basic package already included. So you just copy this script and save it in a file like giveaway.py. And you run the file from the terminal by typing python giveaway.py. This will give you back the closest" near guess" of the participants of your lottery, which you just search for with CTRL+F and the person who wrote that is the de-facto winner.

Instructions

First of all you have to copy all the comments inside a text file. Just copy it as it is, doesn't matter if the formatting will be ugly full of linebreaks and empty spaces, the script will take care of that. You can essentially just press CTRL+A CTRL+C just put the entire page + the comments inside a file, well hopefully your article doesn't contain the numbers but even then you can just parse through your stuff, and select the numbers from the commenter's comments. So for me the text file containing the commenters in my article looks like this:

X1.png

It's long and it's ugly, but it doesn't matter, just make sure it contains all the comments wrote by the participants in your lottery.

Then save this file into something and make sure this file is in the same folder as the script!


I have named it test. In Linux, text files don't have to have an extension, but if you are on Windows or thing like that, use the .txt extension.

Now go and download the python script from here:

Then open the file and configure it:

X2.png

The name of the file + the extension. But in Linux you can just have the file named "test", in Windows it's "test.txt" as you named the file containing the comments.

f1.png

Then set the winner number to the number that would win the lottery. I have already set mine to the number that was the winner in my giveaway.

Then just run the script with python giveaway.py inside the terminal, and the script will give back the number that is the closest to the winner number. So then just search for that number on Steemit with CTRL+F and the person who wrote that is the winner.

Essentially if there are multiple winners you can just parse through them and decide who will win it, or they will be equally shared.

w1.png

So my script returned back 4736, which was written by @tonyr, and that is how @tonyr won 50 SBD in my giveaway.

I hope this script can help many people do giveaways more easier. It works perfectly on Linux, I am not sure about other OS.


Sources:


Upvote, ReSteem & bluebutton


Sort:  

Defo going to be using this when I do giveaways later

Yes I used to be making python scripts for market analysis but my skills were getting rusty, I will have to improve them.

Nice post.... upvoted

Thanks for sharing! Follwoed

Well done mate. Thanks this makes us life easier. Good job.

That's very useful, thank you!

nice man... great talent
You making it easier for others... upvoted
Thanks!!

Cool script! This post deserves a better payout!


Steem Doubler News!
@steemdoubler's ROUND 6 is running! You can enter now!

Thank you for your professional opinion!

Coin Marketplace

STEEM 0.17
TRX 0.15
JST 0.028
BTC 59628.53
ETH 2405.88
USDT 1.00
SBD 2.45