drphil.rb - Voting Bot - gem update and bug fixes

in #radiator6 years ago

New Features

  • Bug/console output fixes.
  • Improved unique_author logic to use account_history instead of internal timer for improved accuracy between runs.
  • Gem update.
  • Additional error handling.
  • Handling bad json_metadata.

Features

  • YAML config.
    • voting_rules
      • winfrey mode that acts like the winfrey bot, all voters vote for everyone
      • drphil mode one random voter votes for everyone (default)
      • following_vote_weight - for accounts that the voter follows
      • followers_vote_weight - for accounts that follow the voter
      • min_rep (default 25.0)
      • min_wait and max_wait (in minutes) so that you can fine-tune voting delay.
      • favorite_accounts list and separate favorites_vote_weight option.
        • Note: votes will be cast for favorites irregardless of rep.
      • enable_comments option to vote for post replies (default false).
      • only_first_posts option to only vote on an author's first post (default false).
      • max_rep option, useful for limiting votes to newer authors (default 99.9).
      • vote_signals account list.
        • Optionally allows multiple bot instances to cooperate by avoiding vote swarms.
        • If enabled, this feature allows cooperation without sharing keys (in drphil mode).
      • min_rep can now accept either a static reputation or a dynamic property.
        • Existing static reputation still supported, e.g.: 25.0
        • Dynamic reputation, e.g.: dynamic:100. This will occasionally query the top 100 trending posts and use the minimum author reputation.
        • Now checking vote_weight: 0.00 % and skipping without broadcast.
          • This is useful for special configurations that only vote for favorites.
        • min_voting_power to create a floor with will allow the voter to recharge over time without having to stop the script.
      • Optionally configure voters as a separate filename. E.g:
        • voters: voters.txt
          • The format for the file is just: account wif (no leading dash, separated by space)
        • Or continue to use the previous format.
      • Also optional support for separate files in each (format one per line or separated by space or both):
        • favorite_accounts
        • skip_accounts
        • skip_tags
        • flag_signals
        • vote_signals
      • only_fully_powered_up which will only vote for posts that receive 100% STEEM Power author rewards.
  • Skip posts with declined payout.
  • Skip posts that already have votes from external scripts and posts that were edited.
  • Argument called replay: allows a replay of n blocks allowing you to catch up to the present.
    • E.g.: ruby drphil.rb replay:90 will replay the last 90 blocks (about 4.5 minutes).
  • Thread management
    • Counter displayed so you know what kind of impact ^C will have.
    • This also keeps the number of threads down when authors edit before Dr. Phil votes.
  • Now streaming on Last Irreversible Block Number, just to be fancy.
  • Now checking for new HF18 cashout_time value (if present).
    • This will skip voting when authors edit their old archived posts.
    • Added unique_author (optional) which takes an integer in minutes. This will limit voting to 1 vote per period. E.g.: Set it to 1440 to only vote for each author once a day.
    • Added max_votes_per_post (optional) which only votes n times per post (winfrey mode only).
    • Added only_tags (optional) which only votes on posts that include these tags.
    • Alternative voting weights all inherit from vote_weight if not present.
    • Favorites (favorite_accounts) can now have individual vote percent.
      • Formatted as: account:weight (e.g.: inertia:100.00)
    • Now checking if any voter can vote at all. If at least one voter has a non-zero vote_weight, return true. Otherwise, don't bother to even queue up a new thread, thus saving memory.
    • Argument called stream:false will exit without streaming the blockchain. Useful in situations where you only want to replay: and exit.

Overview

Dr. Phil (drphil.rb) is reimplementation of the "Winfrey" voting bot specification. The goal is to give everyone an upvote.

One optional improvement is that instead of voting 1% by 100 accounts like the Winfrey bot spec, this script can vote 100% with 1 randomly chosen account.

If the complaint about Winfrey is blockchain bloat, Dr. Phil prescribes weight loss to address this. But this feature would only work if there are enough voters defined in the script. If you plan to use this script for one or two accounts, you'll probably want to adjust the VOTE_WEIGHT constant to something a bit lower.


Install

To use this Radiator bot:

Linux
$ sudo apt-get update
$ sudo apt-get install ruby-full git openssl libssl1.0.0 libssl-dev
$ sudo apt-get upgrade
$ gem install bundler
macOS
$ gem install bundler

I've tested it on various versions of ruby. The oldest one I got it to work was:

ruby 2.0.0p645 (2015-04-13 revision 50299) [x86_64-darwin14.4.0]

First, clone this gist and install the dependencies:

$ git clone https://gist.github.com/61bcc2b821aa5acb24f7fc88921950c7.git drphil
$ cd drphil
$ bundle install

Then run it:

$ ruby drphil.rb

Dr. Phil will now do it's thing. Check here to see an updated version of this bot:


Upgrade

Typically, you can upgrade to the latest version by this command, from the original directory you cloned into:

$ git pull

Usually, this works fine as long as you haven't modified anything. If you get an error, try this:

$ git stash --all
$ git pull --rebase
$ git stash pop

If you're still having problems, I suggest starting a new clone.


Troubleshooting

Problem: What does this error mean?
drphil.yml:1: syntax error, unexpected ':', expecting end-of-input
Solution: You ran ruby drphil.yml but you should run ruby drphil.rb.

Problem: Everything looks ok, but every time Dr. Phil tries to vote, I get this error:
Unable to vote with <account>.  Invalid version
Solution: You're trying to vote with an invalid key.

Make sure the .yml file voter items have the account name, followed by a space, followed by the account's WIF posting key. Also make sure you have removed the example accounts (social and bad.account are just for testing).

Problem: The node I'm using is down.

Is there a list of nodes?

Solution: Yes, special thanks to @ripplerm.

https://ripplerm.github.io/steem-servers/




See my previous Ruby How To posts in: /f/ruby

Get in touch!

If you're using Dr. Phil, I'd love to hear from you. Drop me a line and tell me what you think! I'm @inertia on STEEM and SteemSpeak.

License

I don't believe in intellectual "property". If you do, consider Dr. Phil as licensed under a Creative Commons CC0 License.

Sort:  

@inertia wow I can't really say because I still need to ask questions, is this a new type of bot vote buying?

The way you have represented these codes it's so amazing and all different the 100% part would really make a difference.

Please fill me in, fantastic analysis here

The original goal of this bot was to give everyone an upvote. Legend has it, some people used this bot to vote 1% on every new post. That was in the days of 3,000 active users per day.

These days, people use it as a replacement for Streemian Fanbase™.

Wow that would have been awesome if the original agenda was maintained

Thank you for filling me in on this and great analysis too

Sure, but the problem was that there's not enough voting power to go around. A single account can only vote for about 4,000 people per day at 0.25%, let alone 1%.

I thought delegation would have helped the bot, you know from various users with influence?

@inertia, drphil was working perfectly, implicitly stopped working a day ago, and I do not find the problem. In "Drphil.log" in the last lines it says:
` W, [2018-06-01T17: 09: 33.410252 # 881] WARN -: condenser_api.get_ops_in_block :: Removing misconfigured node from failover urls: https://rpc.curiesteem.com, retrying ... W, [2018-06-01T17: 09: 37.955758 # 881] WARN -: Failing over to https://rpc.buildteam.io ... W, [2018-06-01T17: 09: 41.380394 # 881] WARN -: condenser_api.get_ops_in_block :: Removing misconfigured node from failover urls: https://rpc.buildteam.io, retrying ... W, [2018-06-01T17: 09: 44.681753 # 881] WARN -: Failing over to https://rpc.steemviz.com ... W, [2018-06-01T17: 09: 48.577660 # 881] WARN -: condenser_api.get_ops_in_block :: Removing misconfigured node from failover urls: https://rpc.steemviz.com, retrying ... W, [2018-06-01T17: 09: 49.980104 # 881] WARN -: Failing over to https://steemd.minnowsupportproject.org ... W, [2018-06-01T17: 09: 51.296818 # 881] WARN -: condenser_api.get_ops_in_block :: Removing misconfigured node from failover urls: https://steemd.minnowsupportproject.org, retrying ... E, [2018-06-01T17: 09: 53.846700 # 881] ERROR -: Health check failure for https://rpc.steemliberator.com: # <OpenURI :: HTTPError: 502 Bad Gateway> E, [2018-06-01T17: 09: 55.027698 # 881] ERROR -: Health check failure for https://seed.bitcoiner.me: # <OpenURI :: HTTPError: 404 Not Found> W, [2018-06-01T17: 09: 57.943636 # 881] WARN -: Failing over to https://api.steem.house ... `

I have changed to other active nodes in the "Drphil.yml" configuration, in:
` : chain_options: : chain: steem : url: https://api.steemit.com `

Still, it still does not work.

I would appreciate a help.

Inertia, I am new in this of the healing bots, I have a problem and it is difficult for me to reach the solution. Once inside the directory / drphil $ I try with $ bundle install and the following happens >>>>

Installing ffi 1.9.23 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    /usr/bin/ruby2.1 extconf.rb
Cannot allocate memory - /usr/bin/ruby2.1 extconf.rb 2>&1

Gem files will remain installed in /var/lib/gems/2.1.0/gems/ffi-1.9.23 for
inspection.
Results logged to
/var/lib/gems/2.1.0/extensions/x86_64-linux/2.1.0/ffi-1.9.23/gem_make.out

An error occurred while installing ffi (1.9.23), and Bundler cannot
continue.
Make sure that `gem install ffi -v '1.9.23'` succeeds before bundling.

In Gemfile:
  radiator was resolved to 0.4.1, which depends on
    ffi

I can not solve, I tried update and aupgrade Bundle. Thank you so much.

The bot doesn't require that much memory, but it's possible that bundler needs a bit more in the beginning. Maybe you can enable a temporary swap to get it to bundle:

sudo dd if=/dev/zero of=/var/swap.img bs=1024k count=4000
sudo chmod 600 /var/swap.img
sudo mkswap /var/swap.img
sudo swapon /var/swap.img

Thank you very much for the quick answer. I have made the suggested steps but the same problem persists.

Wow, thank you again. The amzing work you do into this platform is such an added value.. #INERTIAISMASTER

Thanks for all the hard work with the bot! It truly is one of the best out there an I use it to run @qurator. Without it I would be lost! =)

Nice! Thanks @inertia and @seablue for mentioning this in #SteemSpeak

Thanks for your post :-)

Good Result!! Thanks

Very great job

Great news. I'm looking forward to upgrading in the near future and trying out some of the new features.

Inertia thank you for the great work

I'm trying to setup drphil on a raspberry pi3 and it wont let me vote. Maybe I dont have libssl installed correctly ??

I keep getting the following error:
Pausing 0.4 :: Unable to vote with praguepainter. undefined method `regenerate_key' for Bitcoin::OpenSSL_EC:Module

Any idea what I'm doing wrong?

I see this bot votes for everybody, maybe I should use a more targetted bot ? Just wading into the world of curation bots ..
Also I dont understand bandwidth issues .. is there a way to allow the bot to only vote when I have enough bandwidth?

Many thanks

Try:

bundle update

Thanks for your time
I couldnt update ffi

Installing ffi 1.9.21 (was 1.9.18) with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

I'll keep fooling around with it .. .
I'm a noob so perhaps I need a fresh install
Or do it on Jesse on a Pi2 ...

I managed to update by installing libdevffi
still have the regenerate_key error:
Unable to vote with praguepainter. undefined method `regenerate_key' for Bitcoin::OpenSSL_EC:Module

Hey @intertia
LTNS in the chatroom.

I just got the bot running since you changed it adding "gems". I did a fresh install and there have been errors.

It works, recognizes votes that need to be made. Then when it comes time to vote it gives me the following error.

{:error_perser_exception=>#<NoMethodError: undefined method `[]' for nil:NilClass>, :original_response=>{"jsonrpc"=>"2.0", "error"=>{"code"=>-32003, "message"=>"Unable to acquire database lock"}, "id"=>562}}

Any quick solutions come to mind?

That should be an intermittent error. You could also change nodes by editing drphil.yml:

:chain_options:
  :chain: steem
  :url: https://api.steemit.com

... to something else like:

:chain_options:
  :chain: steem
  :url: https://gtg.steem.house:8090

Or pick a different node from this list: https://geo.steem.pl/

Thanks I will try that. Excellent customer service btw.!!! as always.

More info:
You said that the bundler can ask for sudo permission if needed. It didn't.
At first I ran it with sudo (broke the install as you said it would) trashed that VM

Next I read the errors. Gave it read write permission for the directories in could not write to

one: var/lib/gems/

the other was: usr/local/bin

Since the bot is the only thing running - I have no security issues in giving those permissions.

It worked after doing those things. Your work is really interesting. I used to do a lot of programming and would love to see what is under the hood with ruby and gems. Finding the time...

I looked through all my phones and found an installed discord. I was not able to find you or Fyrst, but I will get back to you. Cheers!