Upvote bot in less than 10 lines of code

in #steem9 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?

It would be better if you simply write it in a text file or directly in source code.
When writing in environment variables your whole OS and all programs can find and read it really easy. So could viruses and such things do. And you will probably forget the key in your system when moving the bot to another system.
It's simply a security issue.
That is my answer. There are surely many more reasons.

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.

Why make it easier for people to bring vote quality down? If someone else wants to write their own anti-social bot, they can do it themselves.

The purpose of this post was to show people how easy it has become to write such a bot.
It could do way more than just upvote posts.

The bot can have utility. It can take an article written in one language and translate it to another then post it on Steem.

So for example a person writes an article in Chinese and the bot downloads the text, runs it through a translator process, then uploads the English version. The whole thing can be automated or humans can be rewarded to translate.

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.

Here is an Archive of Cryptocurrency App building Code on Github for anyone creating a Steemit app
https://steemit.com/steem/@marsresident/github-cryptocurrency-app-creation-archive

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.

can i setup this from windows 8.1 ? or only from linux?

That looks like Greek to me. I want to create an upvote bot. Can someone help me? Email me on [email protected] thanks

Thanks man. I really appreciate the time you took to write this library!

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