Class: Cosgrove::Account
Constant Summary
collapse
- DISCORD_IDS =
'discord_ids'.freeze
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Utils
#api, #chain_options, #core_asset, #cycle_api_at, #cycle_stream_at, #debt_asset, #find_author, #find_author_name_permlink, #find_comment, #find_comment_by_slug, #find_transfer, #follow_api, #head_block_number, #last_irreversible_block_num, #new_tx, #parse_slug, #ping_api, #properties, #reset_api, #reset_stream, #stream, #to_rep
Methods included from Config
#channel_disable_comment_voting, #channel_upvote_weight, #cosgrove_allow_pm_commands, #cosgrove_client_id, #cosgrove_disable_comment_voting, #cosgrove_operators, #cosgrove_secure, #cosgrove_token, #cosgrove_upvote_weight, #discord_channels, #discord_fancy_log, #discord_log_mode, #steem_account, #steem_api_failover_urls, #steem_api_url, #steem_posting_wif, #test_api_failover_urls, #test_api_url, #test_posting_wif
Constructor Details
#initialize(account_name, chain = :steem) ⇒ Account
Returns a new instance of Account.
13
14
15
16
17
18
19
20
21
22
23
|
# File 'lib/cosgrove/account.rb', line 13
def initialize(account_name, chain = :steem)
@chain = chain.to_sym
raise "Unknown Chain: #{@chain}" unless Cosgrove::KNOWN_CHAINS.include? @chain
@account_name = account_name.to_s.downcase
@discord_ids = []
if !!details
@discord_ids = details[DISCORD_IDS] || []
end
end
|
Instance Attribute Details
#account_name ⇒ Object
Returns the value of attribute account_name.
11
12
13
|
# File 'lib/cosgrove/account.rb', line 11
def account_name
@account_name
end
|
#discord_ids ⇒ Object
Returns the value of attribute discord_ids.
11
12
13
|
# File 'lib/cosgrove/account.rb', line 11
def discord_ids
@discord_ids
end
|
Class Method Details
.find_by_discord_id(discord_id, chain = :steem) ⇒ Object
25
26
27
28
29
30
31
32
33
34
35
36
37
38
|
# File 'lib/cosgrove/account.rb', line 25
def self.find_by_discord_id(discord_id, chain = :steem)
return if Account.yml[chain.to_s].nil?
discord_id = discord_id.to_s.split('@').last.split('>').first.to_i
return nil if discord_id == 0
Account.yml[chain.to_s].each do |k, v|
ids = v[DISCORD_IDS]
return Account.new(k, chain) if !!ids && ids.include?(discord_id)
end
return nil
end
|
.find_by_memo_key(memo_key, secure, chain = :steem) ⇒ Object
40
41
42
43
44
45
46
47
48
|
# File 'lib/cosgrove/account.rb', line 40
def self.find_by_memo_key(memo_key, secure, chain = :steem)
Account.yml[chain.to_s].each do |k, v|
v[DISCORD_IDS].each do |discord_id|
return Account.new(k, chain) if Account.gen_memo_key(k, discord_id, secure, chain) == memo_key
end
end
return nil
end
|
Instance Method Details
#add_discord_id(discord_id) ⇒ Object
#chain_account ⇒ Object
79
80
81
82
83
84
85
86
87
|
# File 'lib/cosgrove/account.rb', line 79
def chain_account
return @chain_account if !!@chain_account
if !!@account_name
api(@chain).get_accounts([@account_name]) do |accounts, errors|
@chain_account = accounts.first
end
end
end
|
#chain_data ⇒ Object
50
51
52
|
# File 'lib/cosgrove/account.rb', line 50
def chain_data
@chain_data ||= Account.yml[@chain.to_s] || {}
end
|
#details ⇒ Object
54
55
56
57
|
# File 'lib/cosgrove/account.rb', line 54
def details
chain_data[@account_name] ||= {}
chain_data[@account_name]
end
|
#hidden? ⇒ Boolean
59
60
61
|
# File 'lib/cosgrove/account.rb', line 59
def hidden?
!!details['hidden']
end
|
#memo_key(discord_id) ⇒ Object
75
76
77
|
# File 'lib/cosgrove/account.rb', line 75
def memo_key(discord_id)
Account.gen_memo_key(@account_name, discord_id, cosgrove_secure, @chain)
end
|
#novote? ⇒ Boolean
63
64
65
|
# File 'lib/cosgrove/account.rb', line 63
def novote?
!!details['novote']
end
|