Last active
March 22, 2018 22:07
-
-
Save thescubageek/3f5a7f00f39b1b5ccb5f85620869b291 to your computer and use it in GitHub Desktop.
SteemPostBroadcaster
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SteemPostBroadcaster | |
attr_accessor :options | |
def initialize(opts={}) | |
@options = opts | |
end | |
def post! | |
raise "Post is missing title, body, or tags" unless is_valid_post? | |
account.post!(post_options) unless ENV['DISABLE_AUTO_POSTING'].to_boolean | |
end | |
def post_options | |
{ | |
title: @options[:title], | |
body: @options[:body], | |
tags: @options[:tags], | |
percent_steem_dollars: percent_steem_dollars, | |
max_accepted_payout: max_accepted_payout, | |
allow_votes: allow_votes, | |
allow_curation_rewards: allow_curation_rewards | |
#self_vote: self_vote | |
} | |
end | |
def account | |
@account ||= Steem.new(account_name: ENV['ACCOUNT_NAME'], wif: ENV['WIF']) | |
end | |
private | |
def percent_steem_dollars | |
@options.fetch(:percent_steem_dollars, 10000) | |
end | |
def max_accepted_payout | |
@options.fetch(:max_accepted_payout, "1000000.000 SBD") | |
end | |
def allow_votes | |
@options.fetch(:allow_votes, true) | |
end | |
def allow_curation_rewards | |
@options.fetch(:allow_curation_rewards, true) | |
end | |
def self_vote | |
@options.fetch(:self_vote, true) | |
end | |
def is_valid_post? | |
[:title, :body, :tags].all? { |opt| !@options[opt].blank? } | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment