Install two gems
1 - gem install radiator
2 - gem install paint
save this file as easysteem.rb
require 'radiator'
require 'json'
require 'paint'
module EasySteem
module Stream
def Stream.voting_stream
stream = Radiator::Stream.new
stream.operations(:vote) do |op|
print "#{op.voter} voted for #{op.author}"
puts " (weight: #{op.weight / 100.0}%)"
end
end
def Stream.transfer_stream
stream = Radiator::Stream.new
stream.operations(:transfer) do |op|
print "#{Paint[op.from, :green]} has sent #{Paint[op.amount, :red]}"
puts " to #{Paint[op.to, :cyan]} \nMemo: #{Paint[op.memo, :magenta]}"
end
end
def Stream.claim_rewards_stream
stream = Radiator::Stream.new
stream.operations(:claim_reward_balance) do |op|
print "#{Paint[op.account, :green]} has claimed Reward: "
puts "#{Paint[op.reward_sbd, :red]} :: #{Paint[op.reward_steem, :cyan]} :: #{Paint[op.reward_vests, :magenta]}"
end
end
def Stream.delegation_stream
stream = Radiator::Stream.new
stream.operations(:delegate_vesting_shares) do |op|
print "#{Paint[op.delegator, :green]} has delegated #{Paint[op.vesting_shares, :cyan]} "
puts " to #{Paint[op.delegatee, :red]}"
end
end
def Stream.update_account_stream
stream = Radiator::Stream.new
stream.operations(:account_update) do |op|
print "#{Paint[op.account, :green]} has updated his account \n"
end
end
def Stream.comment_stream
stream = Radiator::Stream.new
stream.operations(:comment) do |op|
if op.parent_author != ""
print "#{op.author} commented on #{op.parent_author}\'s Post. "
puts "Permlink: #{op.parent_permlink}"
elsif
print "#{op.author} commented on a Post. \n"
puts "Permlink: #{op.permlink}"
end
end
end
def Stream.follow_stream
stream = Radiator::Stream.new
stream.operations(:custom_json) do |op|
if op.id == "follow"
_myhash = JSON.parse(op.json)
if _myhash[0] == "follow"
_info = _myhash[1]
puts "#{Paint[_info['follower'], :red]} has followed #{Paint[_info['following'], :green]}"
end
end
end
end
def Stream.reblog_stream
stream = Radiator::Stream.new
stream.operations(:custom_json) do |op|
if op.id == "follow"
_myhash = JSON.parse(op.json)
# p _myhash
if _myhash[0] == "reblog"
_info = _myhash[1]
puts "#{Paint[_info['account'], :green]} has shared #{Paint[_info['author'], :cyan]}\'s Post"
end
end
end
end
def Stream.all
stream = Radiator::Stream.new
stream.operations do |op|
_colors = [:green, :red, :cyan, :blue]
_num = Random.new.rand(0.._colors.length)
puts "#{Paint[op, _colors[_num]]}"
end
end
end
module Account
def Account.followers(*options)
api = Radiator::FollowApi.new
if options[2] == nil
_start = 0
elsif
_start = options[2]
end
api.get_followers(options[0], _start, 'blog', options[1]) do |followers|
followers.map(&:follower)
end
end
def Account.following(*options)
api = Radiator::FollowApi.new
if options[2] == nil
_start = 0
elsif
_start = options[2]
end
api.get_following(options[0], _start, 'blog', options[1]) do |followings|
followings.map(&:following)
end
end
def Account.supply
api = Radiator::Api.new
api.get_dynamic_global_properties do |properties|
properties.virtual_supply
end
end
end
end
Once you have that file saved.
Use this module from main.rb
Use it in your programs like this.
require_relative 'easysteem'
## Show virtual Steem supply
puts EasySteem::Account.supply
## Get 10 followers of bilal-haider
puts EasySteem::Account.followers "bilal-haider", 10
## Get 10 people who are followed by bilal-haider
puts EasySteem::Account.following "bilal-haider", 10
## Stream all operations
puts EasySteem::Stream.all
## Stream all voting operations
puts EasySteem::Stream.voting_stream
## Stream all Commenting operations
puts EasySteem::Stream.comment_stream
## Stream all following operations
puts EasySteem::Stream.follow_stream
## Stream all resteem operations
puts EasySteem::Stream.reblog_stream
## Stream all transfer operations
puts EasySteem::Stream.transfer_stream
## Stream all claim reward operations
puts EasySteem::Stream.claim_rewards_stream
## Stream all account updating operations
puts EasySteem::Stream.update_account_stream
good post and very interesting.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
I am glad you liked it :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Wow! This is great content! You have received a free upvote from the Minnows Freedom Project for being a good Steemian and posting original content. To learn more about us or to support us, please visit @minnows-freedom. You can also find us on Discord. Stay cool, create good content and have a nice day!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
What's the syntax for posting code?
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit