module Cosgrove::Config

Public Instance Methods

channel_disable_comment_voting(channel_id) click to toggle source
# File lib/cosgrove/config.rb, line 120
def channel_disable_comment_voting(channel_id)
  rules = yml[:cosgrove][:upvote_rules][:channels]
  default_disable_comment_voting = rules[:default][:disable_comment_voting].to_s == 'true' rescue false
  
  keys = rules.keys - [:default]
  
  disable_comment_voting = keys.map do |key|
    rule = rules[key]
    rule[:disable_comment_voting] if rule[:channel_id] == channel_id
  end.compact.last
  
  disable_comment_voting || default_disable_comment_voting
end
channel_upvote_weight(channel_id) click to toggle source
# File lib/cosgrove/config.rb, line 106
def channel_upvote_weight(channel_id)
  rules = yml[:cosgrove][:upvote_rules][:channels]
  default_weight = rules[:default][:upvote_weight] rescue '0.00 %'
  
  keys = rules.keys - [:default]
  
  weight = keys.map do |key|
    rule = rules[key]
    rule[:upvote_weight] if rule[:channel_id] == channel_id
  end.compact.last
  
  weight || default_weight
end
cosgrove_allow_pm_commands() click to toggle source
# File lib/cosgrove/config.rb, line 19
def cosgrove_allow_pm_commands
  yml[:cosgrove][:allow_pm_commands].to_s == 'true'
end
cosgrove_client_id() click to toggle source
# File lib/cosgrove/config.rb, line 11
def cosgrove_client_id
  yml[:cosgrove][:client_id]
end
cosgrove_disable_comment_voting() click to toggle source
# File lib/cosgrove/config.rb, line 27
def cosgrove_disable_comment_voting
  yml[:cosgrove][:disable_comment_voting].to_s == 'true'
end
cosgrove_operators() click to toggle source
# File lib/cosgrove/config.rb, line 15
def cosgrove_operators
  (yml[:cosgrove][:operators] || '').split(' ')
end
cosgrove_secure() click to toggle source
# File lib/cosgrove/config.rb, line 3
def cosgrove_secure
  yml[:cosgrove][:secure]
end
cosgrove_token() click to toggle source
# File lib/cosgrove/config.rb, line 7
def cosgrove_token
  yml[:cosgrove][:token]
end
cosgrove_upvote_weight() click to toggle source
# File lib/cosgrove/config.rb, line 23
def cosgrove_upvote_weight
  yml[:cosgrove][:upvote_weight]
end
discord_channels() click to toggle source
# File lib/cosgrove/config.rb, line 87
def discord_channels
  return ENV['CHANNELS'].to_s.split(' ') if !!ENV['CHANNELS']
  
  yml[:discord][:channels]
end
discord_fancy_log() click to toggle source
# File lib/cosgrove/config.rb, line 100
def discord_fancy_log
  return false if !!ENV['HELL_ENABLED']
  
  yml[:discord][:fancy_log].to_s == 'true'
end
discord_log_mode() click to toggle source
# File lib/cosgrove/config.rb, line 93
def discord_log_mode
  return :debug if !!ENV['HELL_ENABLED']
  return :info unless !!yml[:discord][:log_mode]
  
  yml[:discord][:log_mode].to_sym
end
hive_account() click to toggle source
# File lib/cosgrove/config.rb, line 71
def hive_account
  chain[:hive_account]
end
hive_api_failover_urls() click to toggle source
# File lib/cosgrove/config.rb, line 43
def hive_api_failover_urls
  [chain[:hive_api_failover_urls]].flatten.compact
end
hive_api_url() click to toggle source
# File lib/cosgrove/config.rb, line 39
def hive_api_url
  chain[:hive_api_url]
end
hive_engine_api_url() click to toggle source
# File lib/cosgrove/config.rb, line 59
def hive_engine_api_url
  (chain[:hive_engine_api_url] rescue nil) || 'https://api.hive-engine.com/rpc'
end
hive_posting_wif() click to toggle source
# File lib/cosgrove/config.rb, line 75
def hive_posting_wif
  chain[:hive_posting_wif]
end
meeseeker_url() click to toggle source
# File lib/cosgrove/config.rb, line 83
def meeseeker_url
  chain[:meeseeker][:url]
end
steem_account() click to toggle source
# File lib/cosgrove/config.rb, line 63
def steem_account
  chain[:steem_account]
end
steem_api_failover_urls() click to toggle source
# File lib/cosgrove/config.rb, line 35
def steem_api_failover_urls
  [chain[:steem_api_failover_urls]].flatten.compact
end
steem_api_url() click to toggle source
# File lib/cosgrove/config.rb, line 31
def steem_api_url
  chain[:steem_api_url]
end
steem_engine_api_url() click to toggle source
# File lib/cosgrove/config.rb, line 55
def steem_engine_api_url
  (chain[:steem_engine_api_url] rescue nil) || 'https://api.steem-engine.com/rpc'
end
steem_posting_wif() click to toggle source
# File lib/cosgrove/config.rb, line 67
def steem_posting_wif
  chain[:steem_posting_wif]
end
test_api_failover_urls() click to toggle source
# File lib/cosgrove/config.rb, line 51
def test_api_failover_urls
  [chain[:test_api_failover_urls]].flatten.compact
end
test_api_url() click to toggle source
# File lib/cosgrove/config.rb, line 47
def test_api_url
  chain[:test_api_url]
end
test_posting_wif() click to toggle source
# File lib/cosgrove/config.rb, line 79
def test_posting_wif
  chain[:test_posting_wif]
end

Private Instance Methods

chain() click to toggle source
# File lib/cosgrove/config.rb, line 134
def chain
  @chain_hash ||= yml[:chain]
end
yml() click to toggle source
# File lib/cosgrove/config.rb, line 138
def yml
  return @yml if !!@yml
  
  config_yaml_path = "#{Cosgrove::PWD}/config.yml"
  
  @yml = if File.exist?(config_yaml_path)
    YAML.load_file(config_yaml_path)
  else
    raise "Create a file: #{config_yaml_path}"
  end
  
  if @yml[:cosgrove].nil? || @yml[:cosgrove][:secure].nil? || @yml[:cosgrove][:secure] == 'set this'
    raise "Set secure key in #{config_yaml_path}."
  end
  
  @yml
end