Skip to content

Instantly share code, notes, and snippets.

@emre

emre/counter.py Secret

Last active July 11, 2018 21:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save emre/0290f033a9b73f1a3d2a663121f9ccf3 to your computer and use it in GitHub Desktop.
Save emre/0290f033a9b73f1a3d2a663121f9ccf3 to your computer and use it in GitHub Desktop.
counter.py
import logging
import time
from beemapi.exceptions import UnhandledRPCError
from beem.account import Account
from beem.comment import Comment
from beem.steem import Steem
TROLL_ACCOUNT = "poritoza"
REAL_ACCOUNT = "emrebeyler"
logger = logging.getLogger(__name__)
logger.setLevel(logging.INFO)
logging.basicConfig()
def main():
s = Steem(
node=["https://rpc.buildteam.io"],
keys=["<private_wif>"],
)
troll_account = Account(TROLL_ACCOUNT, steem_instance=s)
for op in troll_account.history_reverse(only_ops=["vote"]):
permlink = op["permlink"]
if op["weight"] > 0:
logger.info(
"This is an upvote. Nothing to do on this one. %s" % permlink)
return
c = Comment("%s/%s" % (op["author"], permlink))
voters = [v["voter"] for v in c.get("active_votes")]
if TROLL_ACCOUNT in voters and REAL_ACCOUNT not in voters:
if c.get("cashout_time").year == 1969:
continue
try:
c.upvote(+1, voter=REAL_ACCOUNT)
except UnhandledRPCError as e:
if 'Cannot increase payout' in e.args[0]:
continue
raise
time.sleep(4)
logger.info("Upvoted post: %s" % c.identifier)
else:
logger.info("Already voted: %s" % c.identifier)
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment