NEW RANDOM COMMENT PICKER for all contest creators!

Hello! I would like to introduce you to a new hivetool which I created myself.

Random comment picker!

There is many pickers already but adding competitors manualy is not very convenient. I wanted to have a tool working wiith permlinks. So, I created one:

https://hivetools.herokuapp.com/picker/

hivetools.png

I already use this tool for my weekly Rising Star giveaway. It's very easy: just paste permlink, click the button and you will get a winner!

If you required some specific word or words in the comment you can add it in "required words" (uppercase and lowercase does not matter). If not just leave it blank.

Exclude bots: it's "on" by default. It removes all bot comments from the draw. I created bots list manualy. If you have a list of all hive bots I would be appreciate if you share.


Let's take a look at the code in Python.

First we need to import nessecary libraries. "beem" to connect with Hive and "random" to get random winner.
from beem.exceptions import ContentDoesNotExistsException
from beem.comment import Comment
import random

Main function:

def comment_picker(permlink, words="", bots=False):
    try:
        post = Comment(permlink)
    except ContentDoesNotExistsException:
        return 'Post does not exist!'
    except ValueError:
        return 'Wrong permlink format!'
    
    replies = post.get_all_replies()

    if bots == False:
        bot_list = ['pizzabot', 'hivebuzz', 'ecency', 'luvshares', 'beerlover', 'tipu', 'pinmapple']
        replies = [[reply.author, reply.body] for reply in replies if words.lower() in reply.body.lower() and reply.author not in bot_list]
    else:
        replies = [[reply.author, reply.body] for reply in replies if words.lower() in reply.body.lower()]
        
    if not replies:
        return 'No valid comments :('
        
    winner = random.choice(replies)
    participants = set(author for author, body in replies)
    participants.remove(winner[0])

    print('Winner:', winner[0], '\nComment:', winner[1], '\nParticipants:', participants)

Call function "comment_picker()" with permlink as a string and you will get a result. Add words if necessary and bots=True if you want include bots. All seperate with comass. Example:

print(comment_picker('@sentipl/rising-star-weekly-statistics-27', words="I am in"))

The code above is a bit different from the code on the site because I had to adapt it to Django.
If you would like to help develop my site feel free to join the project on github: https://github.com/MarekPas/hivetools

Thanks for reading. Hope you like my tool :)

H2
H3
H4
3 columns
2 columns
1 column
6 Comments
Ecency