Python Libraries: The Random Splash Voter

avatar

Following on from the The Anti-@stimialiti Pro-Active and Reactive Counter Tool, I wanted to write something a little more positive, and as I had the routines already in place, how about a Random Splash Voter?

Here I was with FOUR accounts, not working so well for me in terms of efficiency, pro-actively voting up comments knowing full well they were going to be down-voted on day 6 by a slavering @stimialiti who is still trying in vain to confuse my BOT coding.

image.png

Coming from a professional background in automation, I love the fact that we can code all this boring stuff and let computers do the menial tasks.

I was finding all of the counter-@stimialiti accounts were being underutilised and so the excess voting power needed to get working for me.

Random Splash Voter is the script I came up with from the remnants of the anti-BOT code, which takes a random account from a pre-defined list, gets the latest post that must have been created in the last 24 hours, and then grants it a 100% vote utilising the accounts from my voters' list.

Yes, that’s quite a mouthful and over-worded I know, so let me break it down.

The accounts @chops.support, @wanker, @bingbabe, @dismayedworld have all had some HP delegated to them, and it needs using up on the right kinds of content.

image.png

The script is kicked off manually, gets a random account using this quite simple line, and then checks all FOUR accounts for their voting power levels.

The random account’s posts are obtained that are pending rewards and all are discarded except for the latest one. If that is older than 24 hours then that is also ignored.

…'well... I want full curation for my votes, you can't blame me!'…

If a suitable post is found then each account will bestow a 100% vote if its voting power is above 75%.

image.png

Some HIVE users may have already noticed these votes randomly splashing on their content, and if so you are already part of the voting list.

One problem I did encounter was duplicate voting. For example, if a post has a vote of 50% from an account and then the same weight is attempted again, Python will throw an exception.

I was using a Try: statement to begin to get around this but issues were creeping in if the post was voted twice at different weights.

In this case, the second vote overwrites the first one, nullifying it and denying the voter of curation rewards on the second vote.

image.png

...'HasAuthorVoted returns a Boolean True or False, and takes the parameters of the voter and post data'...

I had to find a more elegant solution than using Try: as it's lazy arse coding and came up with a function that checks the post, enumerates the voters, and returns a Boolean value to the function call.

What I noticed while doing this was when I ran the code, ‘voterlist’ returns a list but it’s really a dictionary.

Enumerating it using dictionary parsing methods such as .keys and .values were all failing so I had to use list commands.

image.png

image.png

I still don’t understand why the (type(voterlist)) command returns a list, so please feel free to educate me.

I have added this routine (above) which can be slotted into anyone’s code.

Lastly, the whole main section is ran by a loop which keeps going until all the accounts are below 75% VP. So I can kick it off, go and have a shower and it's all done when I get out.

image.png

For Python veterans, I suppose all this is quite noddy stuff but I am finding it interesting and have that drive to learn more.

If you have read this far and am not a programmer then your eyes are probably glazed over and you need more coffee, so let’s get to the more interesting part.

image.png

After raiding @steevc's @tenkminnows voting list I now have quite an extensive list of HIVE accounts in my ‘votees’ list but would like some more.

Adding your account to the list gives no guarantee of votes as by design this is a random voter but I can tell you that when I run this script, it passes by many posts as they don't make the criteria.

They are too old, they have already been voted or the VP of the voting accounts is too low. It does skip a lot of content!

image.png

...'sorry @normie.fitness, I will get you next time when the VP level's have gone up some'...

If you want some free votes, are not a spammer, can generate something that people want to read, don't cash out all your rewards, am not already being followed by ME, respond to comments, are not an arsehole, and are generally ignored then feel free to drop me a comment.

I will look over your blog and add you to the list if all the criteria above is met (especially the second to the last one).

Don’t expect massive votes, as these accounts are not large ones, but they will help.

RedLine.png

  • Earn currency while you play brewing virtual beer with CryptoBrewMaster
  • Earn currency while you play and become a global Rock Star with Rising Star


CurieCurator.jpg

RedLine.png

Drooling Maniac.JPG

If you found this article so invigorating that you are now a positively googly-eyed, drooling lunatic with dripping saliva or even if you liked it just a bit, then please upvote, comment, rehive, engage me or all of these things.



0
0
0.000
47 comments
avatar

Woah... you are not just a vampire hunter/ ruined building spelunker, but also kick-ass coder? Sweet!

0
0
0.000
avatar

I do this stuff professionally, but not all of my ilk can code. It gives me the edge when trying to get gigs over the rest. I am a hack and slash coder but can get things to work.

0
0
0.000
avatar

I am just good at copy/paste and then change the variable names. lol

0
0
0.000
avatar

You will soon be a full time python'r!! Good work on the splashing!

0
0
0.000
avatar

It has crossed my mind to look for Python gigs. Can you imagine the interview?

...'I wrote a script to counter votes from some extremist bloke who has it in for me'...

They would not have a clue what I was talking about and may be marched out of the building. We live in a different universe.

0
0
0.000
avatar

That would be funny. When you put it like that it puts into context how nuts and removed from normal everyday life for folk blockchain antics can be!

0
0
0.000
avatar

All fun stuff. I expect some of the code could be made more 'Pythonic'. There are ways to process lists and dictionaries without resorting to a loop, but if it ain't broke...

We can do so much with the beem library. I am looking into other possibilities. I would like to get it running on a Raspberry Pi. I installed it, but got an error as soon as I imported it into a script. I need to look into that some more.

0
0
0.000
avatar

I tried many ways to search the list (that looks like a dictionary). The 'in' command is the easiest and works, but does not find the value. It was a case of what does work in the end. I'm a VB coder, so expect my style to be of that vein.

The Pi does seem a good option to run a script on 24 hours.

0
0
0.000
avatar

If my coding skills only went beyond basic arduino :(
But I'd be happy to be on your list; even though I am not that active those days, maybe I'll be lucky.

Posted via inji.com

0
0
0.000
avatar

Consider yourself added, I have known you long enough.

0
0
0.000
avatar

So you still have to manually start it each day? That seems very tedious :) Just kidding. Nice job. I will have to think of something I want to do sometime and try to write my own code. Just don't get mad if I bug you in Discord every five minutes.

0
0
0.000
avatar

I was tempted to ask about everything when I started. It's better if you can figure it out yourself, the self-satisfaction is quite intense. There are times when a second pair of eyes should be used.

The VP levels of these accounts may now be over 75%, so after running 'wanker_pro_1.4.py' I will be able to run it again in a few hours. It's designed to use only the excess VP, after that other script.

0
0
0.000
avatar

you have come along way since your humble stock lad image.

0
0
0.000
avatar

Dire knew I was an early adaptor computer freak even then but never asked me a thing. I won't elaborate as it's part of another 'Horrors' chapter. IT has done me well over the years, I was never destined to stack shelves forever.

0
0
0.000
avatar

I don't think when you reach a certain age you would be able to lift those boxes of chum and whiskas onto the "top shelf". Fucking hell they were heavy

0
0
0.000
avatar

I am not a programmer, but I do like post and information that shows some of the work flow of python. Some of it is actually beginning to sink in a little bit. Yes it does make the eyes wobbly and gives a sudden desire for coffee, but I did manage to read it all.

Countering adverse actions seems to be a pretty hard thing to do.

0
0
0.000
avatar

With the function call, I included the call to it as well as the function itself. There have been so many times where I wanted to see the call and how it works.. and it's omitted. It's essential for me to see good examples.

0
0
0.000
avatar
(Edited)

I still don’t understand why the (type(voterlist)) command returns a list

I guess it is "active_votes": ["trayciyork","slobberchops","steevc"], hence voterlist=["trayciyork","slobberchops","steevc"], which naturally returns a list as a type

Had to edit the comment to add a suggestion to deal with duplicate votes - to keep a list of items voted on. So if true, vote, add to the list, check if on the list if not, check if true, vote, add to the list...
Just an idea

0
0
0.000
avatar

If you print what (voterlist) returns.. this is what it looks like:

image.png

Those pairings are the hallmarks of a dictionary variable, and yet it insists it's a list.

0
0
0.000
avatar

ok, still a list type ( or better say a list of dictionaries):

[ { }, { }, { } ... { } ]

0
0
0.000
avatar

Since it's [], it's a list.

0
0
0.000
avatar

From what I can see, [] is a list, and {} is a dictionary, so [{}], .. is as @rimicane says, a list of dictionaries.

image.png
Dictionary

image.png
List

It seems there is a such a thing, which I wasn't aware of. The regular 'in' operator as a search does not work on this type so I just messed around with it until I found something that did!

https://pythonexamples.org/python-list-of-dictionaries/

0
0
0.000
avatar
(Edited)

It's a list of JSONs, actually.

0
0
0.000
avatar
for thing in list:
    if thing['voter'] == 'thingey':
        do stuff

Something like this should work.

0
0
0.000
avatar

Yes, that's exactly what I used.

 for item in voterlist:
     if item['voter'] == strvoter:
0
0
0.000
avatar

Youre on another level, im over here slanging manual upvotes like a caveman

0
0
0.000
avatar

I'm right in the mood now for doing some more, need another project!

0
0
0.000
avatar

Nice coding and great initiative man.

I'm fairly confident that I meet all your criteria, although I can't say for sure if I'm an asshole or not! Somone else will have to confirm that bit :)

Anyhow, I post regularly mainly to music, sportstalksocial, haveyoubeenhere and beer and then randomly to some other tribes... Hopefully I meet your criteria for this, if not, no hassle, thanks anyway and it really is a great initiative and at least others will benefit from it.

0
0
0.000
avatar

It all looks alright to me, I see you like your Guinness. Being from Ireland, it couldn't be anything else! You are added.

0
0
0.000
avatar

Ha ha, yep, we certainly like our pints of Guinness here alright, although there have been too many at home and a not enough in the pub over these past few years. I'm really hoping that this will change in 2022 and life can start getting back to some sort of normality. Thanks for adding me man, that's much appreciated.

0
0
0.000
avatar

If you got any questions about been or Python, I am somewhat advanced...

0
0
0.000
avatar

Thanks, this little project is now complete so I will need to think of another... something that is useful. I can't code unless I have my sights on some kind of goal.

0
0
0.000
avatar

Oh look! We vote some of the same people.

0
0
0.000
avatar

I don't know half of those in that list, only that they are not spammers/con-atists/abusers... I hope.

0
0
0.000
avatar

We just hit them very hard if they are bad.

0
0
0.000
avatar

I wish my brain worked this way. I can get it to an extent, but I am more of a puzzle solver, artistic brain type. I have a hard time with musical instruments too.. If I had the free time, this looks like it would be fun to play with and try to learn. Not for a living but for the fun of it! The excitement of making something work for the hell of it.

Hope you get it all figured out and I will be looking forward to maybe catching a "Random" vote. hehehe. Enjoy!!!

0
0
0.000
avatar

The excitement of making something work for the hell of it.

You do get an enormous sense of gratification when producing something unique, as that's what it is. Your code is your own, and there's none other like it.

Hope you get it all figured out and I will be looking forward to maybe catching a "Random" vote.

I am sure some have already gone your way. You were one of the first to be added.

0
0
0.000
avatar

I am sure it has.. But many others need them more than I. Either way I am always grateful. 😁

Can't wait for your next Urban Explorer post.. You have to be running out of abandoned buildings soon! lol

0
0
0.000
avatar

You have to be running out of abandoned buildings soon!

There are many left but I find I have to travel further now. I am still on last July's content yet so have plenty left in the bag. I am going to Liverpool this weekend (weather pending) and have some new ones lined up. You never know what's going to happen, talk about unpredictable!

0
0
0.000
avatar

I can only imagine what one may unexpectedly find on such an adventure.. Hopefully no skeletons. Yikes. You usually find some cool stuff though.

untitled.gif

0
0
0.000
avatar

I was in until you said I couldn't be an arsehole. This is the internet, man! Who wants to be civil? Where's the fun in that?

0
0
0.000
avatar

I have passion for programming.I hope I learn it somedays

0
0
0.000
avatar

Now to be honest I have no idea about what you written here, but I manfully tried to make sense of it.
At the end I realized that even if I read this a hundred times, I would still not have an idea.
So to be fair my way of life includes the saying, to each his own, and I rather leave this kinda stuff to professionals like you.

0
0
0.000
avatar

LOL, I wouldn't expect everyone to understand this (other than free votes). I wish I could call myself a Python Pro, companies are paying big money for services, I have looked.

0
0
0.000
avatar

Well you are not too old to do a python course and a bonus is that you already are familiar with some of it.
Papillon has started a coding course for poor school children, but as I know nothing about it, we partnered with another Non Profit and they have professional tutors that are teaching the kids.

0
0
0.000