Upvote bot in less than 10 lines of code

in #steem8 years ago (edited)

Dear Steemians,

Upvote bot in less than 10 lines of code

from piston.steem import Steem
import os
import json
steem = Steem(wif=os.environ["WIF"])
authors = json.loads(os.environ["AUTHORS"])
for c in steem.stream_comments():
    if c["author"] in authors:
        print(c.upvote())

It reqquires that you put your WIF key and JSON list of AUTHORS into an
environmental variable:

export WIF="<wif-posting-key>" AUTHORS='["xeroc", "dantheman", "ned", "arhag"]'

Note

This currently requries that you install the python-steem library as well as piston from the development branch.

Have fun!

Sort:  

Everyone be like "This is bad, you shouldn't upvote indiscriminately! Y U luv spam, xeroc??" but am I the only one saying "Pardon me, but put your WIF in an environment variable??" ;)

And this is a brilliant hello-world style example of the power and expressiveness of this library. Great work!

Yes, this.

Pardon my ignorance, I'm kind of new, and not all up with what you're trying to say. So it's not a good thing to put your WIF in the environment variable or is it a good thing?

Hey @xeroc, love your stuff but I found a small bug with this logic:

if c["author"] in authors:

This will be true for substring matches in authors.

So if authors contains a name such as "longtestname"
and c["author"] contains a name such as "name" or "test"

It will evaluate as true

(Python is still new for me)

Thanks for taking a closer look, but since this expression

"a" in ["aa"]

evaluates to False in python, I'd say that python interprets all elements of authors independently and in full. That's because authors is an array or list.

If it was just a single author then you would be right since

"a" in "aa"

evaluates to True

Agreed?

Just tested this more and found out what the error was:

If you include the single quotes around the array, both statements return True

stringList = '["list","of","strings"]'
print("list" in stringList)
True
print ("li" in stringList)
True

But if you remove the single quotes around the array, it functions as intended:

stringList = ["list","of","strings"]
print("list" in stringList)
True
print ("li" in stringList)
False

Hope this helps!

In the first case, the stringList is actually a simple string and is not interpreted as an array. that's why the test returns true in both cases.

As much as I like bots and automating things, once an author knows they have certain users "bot voting" for them, they can start to "spam up" inferior content and still be assured of the votes. Also bot users will be favored to get the first couple and most valuable up-votes in. This could be very frustrating for the non-bot community or authors not on the bot list.

Voting is just "one" thing to automate.
You could automate anything with a library like this

Can't the bot scan the text for key words?

This is not good for the system really. To be clear I'm not "blaming" you - people will do what they have to do given a certain rule set. It's just that the system needs to tweak the incentives so that scripted participation, instead of human judgement in terms of quality, is not rewarded. Otherwise what's the point?

I agree with "voting bots" not bringing value. The purpose of this post was to show how easy it is to write one with the new libs.
Technically, you could write any kind of bot with this!

I suppose you could vote first, ask questions later and remove vote if you don't like it.

Forgive a non-techie question. Given two or more users employing the same bot for quick action, which one gets in first? Does it matter where your computer is located and how fast your network speed is, etc.?

Very good questions!!
In fact it depends on who gets his transaction to the next block signer the fastest. That depends on your connectivity and the distance to the next block producer. However, since you don't know the distance to the next block producer and them being spread around the world, it mostly comes down to luck :)

I have several accounts and each time I post I have to log into each one to up-vote my post, so this bot its actually very usefull.. Thanks xeroc!

Wanna to vote against the voting bots. Sorry.

Wow! Few lines of killer bot, thanks mate.. 🙂

It seems your packages have no wheels.

edit:
Nevermind I think I got it
We don't need wheels because we don't need roads where we're going.

Coin Marketplace

STEEM 0.18
TRX 0.13
JST 0.030
BTC 58102.40
ETH 3065.94
USDT 1.00
SBD 2.26