Automating checking for active users with Python

avatar

Last week I put out a post listing Hive users in the UK who are active. This was based on a list compiled by @pennsif, but he himself is inactive lately. Checking for activity was a fair bit of work and I realised it should be possible to automate it.

I posted before about using the beem to query the Hive blockchain. I was able to use some of the same functions for this.

This is from the original post. The new format will be slightly different.

Actually finding UK users is still a manual task as there is there is no one thing to search for in the profile location and many people do not fill it in anyway. I had lots of suggestions after I posted the list. I am now adding them to a text file that looks like this:

R, London & the South East
U, adetorrent
U, andy4475
U, atomcollector
U, basilmarples
U, bleepcoin
U, chris-uk
U, cryptogee

I break it up into regions that start with R and users (U). I am tempted to simplify that. I did a bit of find and replace on the text of my post to generate the file without having to re-type too much. They are mostly alphabetical in the file, but I am sorting the results anyway.

I am saying someone is active if they posted or voted in the last month. Lots of people are just using automatic votes and not actually posting. My script splits out those who just vote and lists as inactive those who at least used Hive since it started.

This is the bit that checks for activity. There are loads of different 'ops' you can check for. I went for those that I thought mattered most for this. I just noticed that the 'comment' op is also used if a post or comment is edited, but I will take that as a sign of activity.

def useractive(user):
    # Work back looking for last post/comment or vote
    acc = Account(user)#, blockchain_instance=hive)
    voted = commented = False

    for a in acc.history_reverse(stop=stop, only_ops=["vote", 
                                                      "comment"]):
        if a["type"] == "vote":
            voted = True
        if a["author"] == user:
            if a["type"] == "comment":
                commented = True
                break # Don't need to check if they voted as well
            
    return (voted, commented)

The rest of the code is just about looping through the users and compiling the lists which are then output in a readable form. You can find all the code in my GitHub. I am using Jupyter Notebook again as it makes for simple experimentation. Scanning over a hundred users takes about three minutes, which is not too bad as I will probably only do this about once per month.

I am still on the lookout for other Brits on Hive to add to the list, so let me know of any you encounter. If you want help adapting this for your own country let me know. It may get unwieldy for many hundreds of people, but that may be a way off in the UK at least.



0
0
0.000
15 comments
avatar

Maybe do a badge thing, offer up a badge to the Users in or from the UK that want to be recognized, then you would have a simple way to check in on them and they would be able to check in on each other, and offer mutual support.

0
0
0.000
avatar

Teyed tgat one for the swiss comunity, ... Gave up on it due to tge difficult process, (for me at least)
!BEER

Posted using Dapplr

0
0
0.000
avatar

There is a badge for UK meetups. I am happy to do this by word of mouth for now. If it gets too big to manage then it's a sign I don't need to make a list any more :)

!ENGAGE 20

0
0
0.000
avatar

Thank you for your engagement on this post, you have recieved ENGAGE tokens.

0
0
0.000
avatar

I onboarded more than 5 people with HIVE from London. They are not currently active but I’ll keep trying to onboarding new people to our HIVE.

0
0
0.000
avatar

If you can let me know of any who post I will add them.

0
0
0.000
avatar

It has been much too long for me. So much of this is over my head. I am glad that you found something to play around with. It does seem like the documentation is very good for all of this. I was always horrible at documentation.

0
0
0.000
avatar

There is lots of potential for coding projects around Hive at all levels. I am just doing simple stuff for now. Maybe I can get to the stage of actually having a bot post stuff, but I need to work out what that can be.

0
0
0.000
avatar

That would be pretty cool.

0
0
0.000