Skip to content

Instantly share code, notes, and snippets.

@inertia186
Last active July 24, 2018 22:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save inertia186/e8325ad50b42f1fd9d01d3dddde397ef to your computer and use it in GitHub Desktop.
Save inertia186/e8325ad50b42f1fd9d01d3dddde397ef to your computer and use it in GitHub Desktop.
This script (chronicle.rb) post with extended posting options. See: https://steemit.com/radiator/@inertia/chronicle-rb-posting-script
Chronicle ('chronicle.rb') for STEEM and GOLOS. Please have a look at the README.md file.
  • Title: chronicle.rb - Posting Script
  • Tags: radiator ruby steem steemdev
  • Notes:

Features

  • YAML config.
    • author
    • post
    • post_options
    • chain_options

Overview

Chronicle (chronicle.rb) is a script that allows you to post with full access to all of the options available on the blockchain. Some of these options are not available in the normal web UI. For instance, you can set a maximum payout of $5 or upvote your post with any percent.


Install

To use this Radiator script:

Linux
$ sudo apt-get install ruby-full git openssl libssl1.0.0 libssl-dev
$ 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/e8325ad50b42f1fd9d01d3dddde397ef.git chronicle
$ cd chronicle
$ bundle install

Then run it:

$ ruby chronicle.rb

Check here to see an updated version of this script:

https://gist.github.com/inertia186/e8325ad50b42f1fd9d01d3dddde397ef


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?
chronicle.yml:1: syntax error, unexpected ':', expecting end-of-input
Solution: You ran ruby chronicle.yml but you should run ruby chronicle.rb.

Problem: Everything looks ok, but every time Chronicle tries to post, I get this error:
`from_base58': Invalid version (RuntimeError)
Solution: You're trying to vote with an invalid key.

Make sure the .yml file author item has the correct account name and WIF posting key.

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: #radiator #ruby

Get in touch!

If you're using Chronicle, 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 Chronicle as licensed under a Creative Commons CC0 License.

require 'rubygems'
require 'bundler/setup'
require 'yaml'
require 'pry'
Bundler.require
AGENT_ID = 'chronicle/0.0.1'
chronicle_path = __FILE__.sub(/\.rb$/, '.yml')
unless File.exist? chronicle_path
puts "Unable to find: #{chronicle_path}"
exit
end
chronicle = YAML.load_file(chronicle_path)
author = chronicle[:author]
post = chronicle[:post]
post_options = chronicle[:post_options]
chain_options = chronicle[:chain_options]
metadata = {app: AGENT_ID}
if !!post[:tags] && post[:tags].any?
tags = [post.delete(:tags)].flatten
metadata[:tags] = tags
post[:parent_permlink] ||= tags.first
end
post[:type] = :comment
post[:parent_author] = ''
post[:author] = author[:account]
post[:json_metadata] = metadata.to_json
upvote = (post_options.delete(:upvote).to_f * 100).to_i
unless upvote == 0
vote = {
type: :vote,
voter: author[:account],
author: author[:account],
permlink: post[:permlink],
weight: upvote
}
end
post_options[:type] = :comment_options
post_options[:author] = author[:account]
post_options[:permlink] = post[:permlink]
post_options[:percent_steem_dollars] = (post_options[:percent_steem_dollars].to_f * 100).to_i
post_options[:extensions] = []
tx = Radiator::Transaction.new(chain_options.dup.merge(wif: author[:posting_wif]))
ops = [Radiator::Operation.new(post), Radiator::Operation.new(post_options)]
ops << Radiator::Operation.new(vote) unless vote.nil?
tx.operations = ops
response = tx.process(true)
puts response
:author:
:account: social
:posting_wif: 5JrvPrQeBBvCRdjv29iDvkwn3EQYZ9jqfAHzrCyUvfbEbRkrYFC
:post:
:permlink: lorem-ipsum
:title: Lorem Ipsum
:tags:
- tag1
- tag2
- tag3
- tag4
- tag5
:body: |
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod
tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam,
quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo
consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse
cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat
non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
<center>
<img src="http://i.imgur.com/grXqcNw.gif" />
</center>
:post_options:
:upvote: 100.00 %
:max_accepted_payout: 1000000.000 SBD
:percent_steem_dollars: 100.00 %
:allow_votes: true
:allow_curation_rewards: true
:chain_options:
:chain: steem
:url: https://steemd.steemit.com
source 'https://rubygems.org'
gem 'radiator', git: 'https://github.com/inertia186/radiator.git'
gem 'pry'
GIT
remote: https://github.com/inertia186/radiator.git
revision: 8260788471efb27ceec58f2c3c86f98f2a199991
specs:
radiator (0.1.3)
bitcoin-ruby (= 0.0.10)
ffi (= 1.9.17)
hashie (>= 1.1)
json (~> 1.8.6)
logging (~> 2.2.0)
net-http-persistent (~> 2.9.4)
GEM
remote: https://rubygems.org/
specs:
bitcoin-ruby (0.0.10)
coderay (1.1.1)
ffi (1.9.17)
hashie (3.5.5)
json (1.8.6)
little-plugger (1.1.4)
logging (2.2.2)
little-plugger (~> 1.1)
multi_json (~> 1.10)
method_source (0.8.2)
multi_json (1.12.1)
net-http-persistent (2.9.4)
pry (0.10.4)
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
slop (3.6.0)
PLATFORMS
ruby
DEPENDENCIES
pry
radiator!
BUNDLED WITH
1.14.3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment