cosgrove 0.0.3.5 → 0.0.4.0pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile +2 -1
- data/Gemfile.lock +72 -80
- data/cosgrove.gemspec +4 -7
- data/lib/cosgrove.rb +1 -9
- data/lib/cosgrove/bot.rb +0 -2
- data/lib/cosgrove/market.rb +23 -27
- data/lib/cosgrove/support.rb +13 -43
- data/lib/cosgrove/upvote_job.rb +1 -1
- data/lib/cosgrove/utils.rb +10 -25
- data/lib/cosgrove/version.rb +1 -1
- metadata +17 -58
- data/mongoid.yml +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: 30ef938779ca56743ce5f8a4fa9612e251dc98d92fd0b7f92d30cf6fcbb9cc13
|
4
|
+
data.tar.gz: 31e31742772dc409ca264638289b13eab63952686d5d4eb10e7d0a87b318d16e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a39ed8012f5c4baa02be75eafdd19def80d4f27d55f924a1b0214592843a0f33bc2db5ebf2620e57e6c5fc5ba21df5ed8fe6d73dfc97943d5dd3764217fb51cb
|
7
|
+
data.tar.gz: 0a0d21235b281c8085e90e65f675c6300f7825a78594e4aa475f60e593889284d3a8237915d15d0104f149da0b8ca5ef08e4a2a6ed5ed9e882f466f0e0824374
|
data/Gemfile
CHANGED
data/Gemfile.lock
CHANGED
@@ -1,67 +1,50 @@
|
|
1
|
-
GIT
|
2
|
-
remote: https://github.com/sparklemotion/mechanize.git
|
3
|
-
revision: f68b1a0bdeee9ec7c9a8b7854f8e6b81d62c43b2
|
4
|
-
branch: upgrade_net-http-persistent
|
5
|
-
specs:
|
6
|
-
mechanize (2.7.5)
|
7
|
-
domain_name (~> 0.5, >= 0.5.1)
|
8
|
-
http-cookie (~> 1.0)
|
9
|
-
mime-types (>= 1.17.2)
|
10
|
-
net-http-digest_auth (~> 1.1, >= 1.1.1)
|
11
|
-
net-http-persistent (>= 2.5.2)
|
12
|
-
nokogiri (~> 1.6)
|
13
|
-
ntlm-http (~> 0.1, >= 0.1.1)
|
14
|
-
webrobots (>= 0.0.9, < 0.2)
|
15
|
-
|
16
1
|
PATH
|
17
2
|
remote: .
|
18
3
|
specs:
|
19
|
-
cosgrove (0.0.
|
4
|
+
cosgrove (0.0.4.0pre1)
|
20
5
|
activesupport (~> 5.1, >= 5.1.1)
|
21
6
|
ai4r (~> 1.13, >= 1.13)
|
22
7
|
awesome_print (~> 1.7, >= 1.7.0)
|
23
8
|
discordrb (~> 3.2, >= 3.2.1)
|
24
9
|
golos_cloud (~> 1.1, >= 1.1.1rc1)
|
25
10
|
mechanize (~> 2.7, >= 2.7.5)
|
26
|
-
mongoid (~> 6.1, >= 6.1.0)
|
27
11
|
phantomjs (~> 2.1, >= 2.1.1.0)
|
28
|
-
radiator (~> 0.
|
12
|
+
radiator (~> 0.4, >= 0.4.3)
|
29
13
|
railties (~> 5.1, >= 5.1.1)
|
30
14
|
rdiscount (~> 2.2, >= 2.2.0.1)
|
31
15
|
rmagick (~> 2.16, >= 2.16.0)
|
32
16
|
steem-slap (~> 0.0, >= 0.0.2)
|
33
17
|
steem_api (~> 1.1, >= 1.1.1rc1)
|
34
|
-
steem_data (~> 0.0, >= 0.0.3)
|
35
18
|
wolfram-alpha (~> 0.3, >= 0.3.1)
|
36
19
|
|
37
20
|
GEM
|
38
21
|
remote: https://rubygems.org/
|
39
22
|
specs:
|
40
|
-
actionpack (5.1.
|
41
|
-
actionview (= 5.1.
|
42
|
-
activesupport (= 5.1.
|
23
|
+
actionpack (5.1.6)
|
24
|
+
actionview (= 5.1.6)
|
25
|
+
activesupport (= 5.1.6)
|
43
26
|
rack (~> 2.0)
|
44
27
|
rack-test (>= 0.6.3)
|
45
28
|
rails-dom-testing (~> 2.0)
|
46
29
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
47
|
-
actionview (5.1.
|
48
|
-
activesupport (= 5.1.
|
30
|
+
actionview (5.1.6)
|
31
|
+
activesupport (= 5.1.6)
|
49
32
|
builder (~> 3.1)
|
50
33
|
erubi (~> 1.4)
|
51
34
|
rails-dom-testing (~> 2.0)
|
52
35
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
53
|
-
activemodel (5.1.
|
54
|
-
activesupport (= 5.1.
|
55
|
-
activerecord (5.1.
|
56
|
-
activemodel (= 5.1.
|
57
|
-
activesupport (= 5.1.
|
36
|
+
activemodel (5.1.6)
|
37
|
+
activesupport (= 5.1.6)
|
38
|
+
activerecord (5.1.6)
|
39
|
+
activemodel (= 5.1.6)
|
40
|
+
activesupport (= 5.1.6)
|
58
41
|
arel (~> 8.0)
|
59
42
|
activerecord-sqlserver-adapter (5.1.6)
|
60
43
|
activerecord (~> 5.1.0)
|
61
44
|
tiny_tds
|
62
|
-
activesupport (5.1.
|
45
|
+
activesupport (5.1.6)
|
63
46
|
concurrent-ruby (~> 1.0, >= 1.0.2)
|
64
|
-
i18n (
|
47
|
+
i18n (>= 0.7, < 2)
|
65
48
|
minitest (~> 5.1)
|
66
49
|
tzinfo (~> 1.1)
|
67
50
|
addressable (2.5.2)
|
@@ -69,63 +52,69 @@ GEM
|
|
69
52
|
ai4r (1.13)
|
70
53
|
arel (8.0.0)
|
71
54
|
awesome_print (1.8.0)
|
72
|
-
bitcoin-ruby (0.0.
|
73
|
-
bson (4.3.0)
|
55
|
+
bitcoin-ruby (0.0.18)
|
74
56
|
builder (3.2.3)
|
75
|
-
|
57
|
+
coderay (1.1.2)
|
58
|
+
concurrent-ruby (1.1.3)
|
76
59
|
connection_pool (2.2.1)
|
77
60
|
crack (0.4.3)
|
78
61
|
safe_yaml (~> 1.0.0)
|
79
|
-
crass (1.0.
|
80
|
-
discordrb (3.
|
81
|
-
discordrb-webhooks (~> 3.
|
62
|
+
crass (1.0.4)
|
63
|
+
discordrb (3.3.0)
|
64
|
+
discordrb-webhooks (~> 3.3.0)
|
65
|
+
ffi (>= 1.9.24)
|
82
66
|
opus-ruby
|
83
67
|
rbnacl (~> 3.4.0)
|
84
|
-
rest-client
|
68
|
+
rest-client (>= 2.1.0.rc1)
|
85
69
|
websocket-client-simple (>= 0.3.0)
|
86
|
-
discordrb-webhooks (3.
|
87
|
-
rest-client
|
88
|
-
docile (1.
|
89
|
-
domain_name (0.5.
|
70
|
+
discordrb-webhooks (3.3.0)
|
71
|
+
rest-client (>= 2.1.0.rc1)
|
72
|
+
docile (1.3.0)
|
73
|
+
domain_name (0.5.20180417)
|
90
74
|
unf (>= 0.0.5, < 1.0.0)
|
91
|
-
erubi (1.7.
|
75
|
+
erubi (1.7.1)
|
92
76
|
event_emitter (0.2.6)
|
93
|
-
ffi (1.9.
|
94
|
-
golos_cloud (1.1.
|
77
|
+
ffi (1.9.25)
|
78
|
+
golos_cloud (1.1.1)
|
95
79
|
activerecord (>= 4, < 6)
|
96
80
|
activerecord-sqlserver-adapter (>= 4, < 6)
|
97
81
|
nokogiri (~> 1.8)
|
98
82
|
rest-client (~> 2.0)
|
99
83
|
tiny_tds (~> 1.3)
|
100
84
|
hashdiff (0.3.7)
|
101
|
-
hashie (3.
|
85
|
+
hashie (3.6.0)
|
86
|
+
http-accept (1.7.0)
|
102
87
|
http-cookie (1.0.3)
|
103
88
|
domain_name (~> 0.5)
|
104
|
-
i18n (
|
89
|
+
i18n (1.1.1)
|
105
90
|
concurrent-ruby (~> 1.0)
|
106
91
|
json (2.1.0)
|
107
92
|
little-plugger (1.1.4)
|
108
93
|
logging (2.2.2)
|
109
94
|
little-plugger (~> 1.1)
|
110
95
|
multi_json (~> 1.10)
|
111
|
-
loofah (2.
|
96
|
+
loofah (2.2.3)
|
112
97
|
crass (~> 1.0.2)
|
113
98
|
nokogiri (>= 1.5.9)
|
99
|
+
mechanize (2.7.6)
|
100
|
+
domain_name (~> 0.5, >= 0.5.1)
|
101
|
+
http-cookie (~> 1.0)
|
102
|
+
mime-types (>= 1.17.2)
|
103
|
+
net-http-digest_auth (~> 1.1, >= 1.1.1)
|
104
|
+
net-http-persistent (>= 2.5.2)
|
105
|
+
nokogiri (~> 1.6)
|
106
|
+
ntlm-http (~> 0.1, >= 0.1.1)
|
107
|
+
webrobots (>= 0.0.9, < 0.2)
|
114
108
|
method_source (0.9.0)
|
115
109
|
mime-types (3.1)
|
116
110
|
mime-types-data (~> 3.2015)
|
117
111
|
mime-types-data (3.2016.0521)
|
118
112
|
mini_portile2 (2.3.0)
|
119
113
|
minitest (5.11.3)
|
120
|
-
minitest-line (0.6.
|
114
|
+
minitest-line (0.6.5)
|
121
115
|
minitest (~> 5.0)
|
122
116
|
minitest-proveit (1.0.0)
|
123
117
|
minitest (> 5, < 7)
|
124
|
-
mongo (2.5.0)
|
125
|
-
bson (>= 4.3.0, < 5.0.0)
|
126
|
-
mongoid (6.3.0)
|
127
|
-
activemodel (~> 5.1)
|
128
|
-
mongo (>= 2.5.0, < 3.0.0)
|
129
118
|
multi_json (1.13.1)
|
130
119
|
net-http-digest_auth (1.4.1)
|
131
120
|
net-http-persistent (3.0.0)
|
@@ -137,11 +126,14 @@ GEM
|
|
137
126
|
opus-ruby (1.0.1)
|
138
127
|
ffi
|
139
128
|
phantomjs (2.1.1.0)
|
140
|
-
|
141
|
-
|
142
|
-
|
129
|
+
pry (0.11.3)
|
130
|
+
coderay (~> 1.1.0)
|
131
|
+
method_source (~> 0.9.0)
|
132
|
+
public_suffix (3.0.2)
|
133
|
+
rack (2.0.6)
|
134
|
+
rack-test (1.1.0)
|
143
135
|
rack (>= 1.0, < 3)
|
144
|
-
radiator (0.3
|
136
|
+
radiator (0.4.3)
|
145
137
|
awesome_print (~> 1.7, >= 1.7.0)
|
146
138
|
bitcoin-ruby (~> 0.0, >= 0.0.11)
|
147
139
|
ffi (~> 1.9, >= 1.9.18)
|
@@ -152,40 +144,39 @@ GEM
|
|
152
144
|
rails-dom-testing (2.0.3)
|
153
145
|
activesupport (>= 4.2.0)
|
154
146
|
nokogiri (>= 1.6)
|
155
|
-
rails-html-sanitizer (1.0.
|
156
|
-
loofah (~> 2.
|
157
|
-
railties (5.1.
|
158
|
-
actionpack (= 5.1.
|
159
|
-
activesupport (= 5.1.
|
147
|
+
rails-html-sanitizer (1.0.4)
|
148
|
+
loofah (~> 2.2, >= 2.2.2)
|
149
|
+
railties (5.1.6)
|
150
|
+
actionpack (= 5.1.6)
|
151
|
+
activesupport (= 5.1.6)
|
160
152
|
method_source
|
161
153
|
rake (>= 0.8.7)
|
162
154
|
thor (>= 0.18.1, < 2.0)
|
163
|
-
rake (12.3.
|
155
|
+
rake (12.3.1)
|
164
156
|
rbnacl (3.4.0)
|
165
157
|
ffi
|
166
158
|
rdiscount (2.2.0.1)
|
167
|
-
rest-client (2.0.
|
159
|
+
rest-client (2.1.0.rc1)
|
160
|
+
http-accept (>= 1.7.0, < 2.0)
|
168
161
|
http-cookie (>= 1.0.2, < 2.0)
|
169
162
|
mime-types (>= 1.16, < 4.0)
|
170
163
|
netrc (~> 0.8)
|
171
164
|
rmagick (2.16.0)
|
172
165
|
safe_yaml (1.0.4)
|
173
|
-
simplecov (0.
|
174
|
-
docile (~> 1.1
|
166
|
+
simplecov (0.16.1)
|
167
|
+
docile (~> 1.1)
|
175
168
|
json (>= 1.8, < 3)
|
176
169
|
simplecov-html (~> 0.10.0)
|
177
170
|
simplecov-html (0.10.2)
|
178
171
|
steem-slap (0.0.4)
|
179
|
-
steem_api (1.1.
|
172
|
+
steem_api (1.1.1)
|
180
173
|
activerecord (>= 4, < 6)
|
181
174
|
activerecord-sqlserver-adapter (>= 4, < 6)
|
182
175
|
awesome_print (~> 1.7, >= 1.7.0)
|
183
176
|
nokogiri (~> 1.8)
|
184
177
|
rest-client (~> 2.0)
|
185
178
|
tiny_tds (~> 1.3)
|
186
|
-
|
187
|
-
mongoid (~> 6.1, >= 6.1.0)
|
188
|
-
thor (0.20.0)
|
179
|
+
thor (0.20.3)
|
189
180
|
thread_safe (0.3.6)
|
190
181
|
tiny_tds (1.3.0)
|
191
182
|
mini_portile2 (~> 2.0)
|
@@ -193,20 +184,20 @@ GEM
|
|
193
184
|
thread_safe (~> 0.1)
|
194
185
|
unf (0.1.4)
|
195
186
|
unf_ext
|
196
|
-
unf_ext (0.0.7.
|
187
|
+
unf_ext (0.0.7.5)
|
197
188
|
vcr (3.0.3)
|
198
|
-
webmock (3.
|
189
|
+
webmock (3.4.1)
|
199
190
|
addressable (>= 2.3.6)
|
200
191
|
crack (>= 0.3.2)
|
201
192
|
hashdiff
|
202
193
|
webrobots (0.1.2)
|
203
|
-
websocket (1.2.
|
194
|
+
websocket (1.2.8)
|
204
195
|
websocket-client-simple (0.3.0)
|
205
196
|
event_emitter
|
206
197
|
websocket
|
207
198
|
wolfram-alpha (0.3.1)
|
208
199
|
nokogiri
|
209
|
-
yard (0.9.
|
200
|
+
yard (0.9.16)
|
210
201
|
|
211
202
|
PLATFORMS
|
212
203
|
ruby
|
@@ -214,15 +205,16 @@ PLATFORMS
|
|
214
205
|
DEPENDENCIES
|
215
206
|
bundler (~> 1.15, >= 1.15.4)
|
216
207
|
cosgrove!
|
217
|
-
mechanize
|
218
|
-
minitest (~> 5.
|
219
|
-
minitest-line (~> 0.6, >= 0.6.
|
208
|
+
mechanize
|
209
|
+
minitest (~> 5.10, >= 5.10.3)
|
210
|
+
minitest-line (~> 0.6, >= 0.6.4)
|
220
211
|
minitest-proveit (~> 1.0, >= 1.0.0)
|
212
|
+
pry
|
221
213
|
rake (~> 12.1, >= 12.1.0)
|
222
214
|
simplecov (~> 0.11, >= 0.11.2)
|
223
215
|
vcr (~> 3.0, >= 3.0.3)
|
224
216
|
webmock (~> 3.0, >= 3.0.1)
|
225
|
-
yard (~> 0.9, >= 0.9.
|
217
|
+
yard (~> 0.9, >= 0.9.16)
|
226
218
|
|
227
219
|
BUNDLED WITH
|
228
|
-
1.16.
|
220
|
+
1.16.5
|
data/cosgrove.gemspec
CHANGED
@@ -20,21 +20,18 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_development_dependency 'bundler', '~> 1.15', '>= 1.15.4'
|
21
21
|
spec.add_development_dependency 'rake', '~> 12.1', '>= 12.1.0'
|
22
22
|
spec.add_development_dependency 'minitest-proveit', '~> 1.0', '>= 1.0.0'
|
23
|
-
spec.add_development_dependency 'minitest', '~> 5.
|
24
|
-
spec.add_development_dependency 'minitest-line', '~> 0.6', '>= 0.6.
|
23
|
+
spec.add_development_dependency 'minitest', '~> 5.10', '>= 5.10.3'
|
24
|
+
spec.add_development_dependency 'minitest-line', '~> 0.6', '>= 0.6.4'
|
25
25
|
spec.add_development_dependency 'webmock', '~> 3.0', '>= 3.0.1'
|
26
26
|
spec.add_development_dependency 'vcr', '~> 3.0', '>= 3.0.3'
|
27
27
|
spec.add_development_dependency 'simplecov', '~> 0.11', '>= 0.11.2'
|
28
|
-
spec.add_development_dependency 'yard', '~> 0.9', '>= 0.9.
|
29
|
-
# spec.add_development_dependency 'pry', '~> 0.10', '>= 0.10.3'
|
28
|
+
spec.add_development_dependency 'yard', '~> 0.9', '>= 0.9.16'
|
30
29
|
|
31
|
-
spec.add_dependency 'radiator', '~> 0.
|
32
|
-
spec.add_dependency 'steem_data', '~> 0.0', '>= 0.0.3'
|
30
|
+
spec.add_dependency 'radiator', '~> 0.4', '>= 0.4.3'
|
33
31
|
spec.add_dependency 'steem_api', '~> 1.1', '>= 1.1.1rc1'
|
34
32
|
spec.add_dependency 'golos_cloud', '~> 1.1', '>= 1.1.1rc1'
|
35
33
|
spec.add_dependency 'discordrb', '~> 3.2', '>= 3.2.1'
|
36
34
|
spec.add_dependency 'ai4r', '~> 1.13', '>= 1.13'
|
37
|
-
spec.add_dependency 'mongoid', '~> 6.1', '>= 6.1.0'
|
38
35
|
spec.add_dependency 'steem-slap', '~> 0.0', '>= 0.0.2'
|
39
36
|
spec.add_dependency 'activesupport', '~> 5.1', '>= 5.1.1'
|
40
37
|
spec.add_dependency 'railties', '~> 5.1', '>= 5.1.1'
|
data/lib/cosgrove.rb
CHANGED
@@ -4,25 +4,17 @@ require 'yaml'
|
|
4
4
|
require 'action_view'
|
5
5
|
require 'radiator'
|
6
6
|
require 'awesome_print'
|
7
|
-
require 'steem_data'
|
8
7
|
require 'steem_api'
|
9
8
|
require 'golos_cloud'
|
10
|
-
# require 'irb' # for binding.irb
|
11
9
|
# require 'pry' # for binding.pry
|
12
10
|
|
13
11
|
Bundler.require
|
14
12
|
|
15
13
|
defined? Thread.report_on_exception and Thread.report_on_exception = true
|
16
14
|
|
17
|
-
SteemData.load
|
18
|
-
|
19
|
-
# This will cause a nil to be returned instead of raising an error, allowing us
|
20
|
-
# to fall back to SteemApi and/or RPC.
|
21
|
-
Mongoid.raise_not_found_error = false
|
22
|
-
|
23
15
|
module Cosgrove
|
24
16
|
PWD = Dir.pwd.freeze
|
25
|
-
KNOWN_CHAINS = [:steem, :
|
17
|
+
KNOWN_CHAINS = [:steem, :test]
|
26
18
|
|
27
19
|
require 'cosgrove/version'
|
28
20
|
require 'cosgrove/phantomjs'
|
data/lib/cosgrove/bot.rb
CHANGED
@@ -60,7 +60,6 @@ module Cosgrove
|
|
60
60
|
return if event.channel.pm? && !cosgrove_allow_pm_commands
|
61
61
|
cb_account = nil
|
62
62
|
|
63
|
-
mongo_behind_warning(event)
|
64
63
|
if key.nil?
|
65
64
|
event.respond "To create an account: https://steemit.com/enter_email?r=#{steem_account}"
|
66
65
|
return
|
@@ -97,7 +96,6 @@ module Cosgrove
|
|
97
96
|
self.command :register do |event, account_name, chain = :steem|
|
98
97
|
return if event.channel.pm? && !cosgrove_allow_pm_commands
|
99
98
|
|
100
|
-
mongo_behind_warning(event)
|
101
99
|
discord_id = event.author.id
|
102
100
|
|
103
101
|
if discord_id.to_i == 0
|
data/lib/cosgrove/market.rb
CHANGED
@@ -2,18 +2,25 @@ module Cosgrove
|
|
2
2
|
module Market
|
3
3
|
include Support
|
4
4
|
include ActionView::Helpers::NumberHelper
|
5
|
-
|
5
|
+
|
6
|
+
def base_per_mvest(chain = :steem)
|
7
|
+
api(chain).get_dynamic_global_properties do |properties|
|
8
|
+
total_vesting_fund_steem = properties.total_vesting_fund_steem.to_f
|
9
|
+
total_vesting_shares_mvest = properties.total_vesting_shares.to_f / 1e6
|
10
|
+
|
11
|
+
total_vesting_fund_steem / total_vesting_shares_mvest
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
6
15
|
def price_feed(chain = :steem)
|
7
16
|
api(chain).get_feed_history do |feed_history|
|
8
|
-
base_per_mvest = api(chain).steem_per_mvest
|
9
|
-
|
10
17
|
current_median_history = feed_history.current_median_history
|
11
18
|
base = current_median_history.base
|
12
19
|
base = base.split(' ').first.to_f
|
13
20
|
quote = current_median_history.quote
|
14
21
|
quote = quote.split(' ').first.to_f
|
15
22
|
|
16
|
-
base_per_debt = (base / quote) * base_per_mvest
|
23
|
+
base_per_debt = (base / quote) * base_per_mvest(chain)
|
17
24
|
|
18
25
|
[base_per_mvest, base_per_debt]
|
19
26
|
end
|
@@ -125,24 +132,13 @@ module Cosgrove
|
|
125
132
|
end
|
126
133
|
|
127
134
|
account_names = account_names.map(&:downcase).uniq
|
128
|
-
accounts =
|
129
|
-
account = accounts.
|
130
|
-
|
131
|
-
if accounts.size == 0
|
132
|
-
accounts = SteemApi::Account.where(name: account_names)
|
133
|
-
account = accounts.limit(1).last
|
134
|
-
end
|
135
|
+
accounts = SteemApi::Account.where(name: account_names)
|
136
|
+
account = accounts.limit(1).first
|
135
137
|
|
136
138
|
if accounts.count == account_names.size
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
received_vests = accounts.sum('received_vesting_shares.amount')
|
141
|
-
else
|
142
|
-
vests = accounts.pluck(:vesting_shares).map(&:to_f).sum
|
143
|
-
delegated_vests = accounts.pluck(:delegated_vesting_shares).map(&:to_f).sum
|
144
|
-
received_vests = accounts.pluck(:received_vesting_shares).map(&:to_f).sum
|
145
|
-
end
|
139
|
+
vests = accounts.pluck(:vesting_shares).map(&:to_f).sum
|
140
|
+
delegated_vests = accounts.pluck(:delegated_vesting_shares).map(&:to_f).sum
|
141
|
+
received_vests = accounts.pluck(:received_vesting_shares).map(&:to_f).sum
|
146
142
|
elsif !wildcards
|
147
143
|
valid_names = accounts.distinct(:name)
|
148
144
|
unknown_names = account_names - valid_names
|
@@ -209,7 +205,7 @@ module Cosgrove
|
|
209
205
|
usd = number_to_currency(usd, precision: 3)
|
210
206
|
|
211
207
|
"**#{account.name}:** `#{mgests} MGESTS = #{golos} GOLOS = #{gbg} GBG = #{usd}`"
|
212
|
-
when :test then "Query not supported. No
|
208
|
+
when :test then "Query not supported. No database for Testnet."
|
213
209
|
end
|
214
210
|
end
|
215
211
|
|
@@ -267,11 +263,11 @@ module Cosgrove
|
|
267
263
|
end
|
268
264
|
|
269
265
|
def promoted(chain = :steem, period = :today)
|
270
|
-
return "Query not supported. No
|
266
|
+
return "Query not supported. No database for #{chain.to_s.capitalize}." unless chain == :steem
|
271
267
|
|
272
|
-
promoted =
|
268
|
+
promoted = SteemApi::Tx::Transfer.where(to: 'null', amount_symbol: 'SBD').send(period)
|
273
269
|
count_promoted = promoted.count
|
274
|
-
sum_promoted = promoted.sum(
|
270
|
+
sum_promoted = promoted.sum(:amount)
|
275
271
|
|
276
272
|
base_per_mvest, base_per_debt = price_feed(chain)
|
277
273
|
total = api(chain).get_reward_fund('post') do |reward_fund|
|
@@ -362,9 +358,9 @@ module Cosgrove
|
|
362
358
|
chain = options[:chain] || :steem
|
363
359
|
account_names = options[:account_names]
|
364
360
|
case chain
|
365
|
-
when :steem then
|
366
|
-
when :golos then "Query not supported. No
|
367
|
-
when :test then "Query not supported. No
|
361
|
+
when :steem then SteemApi::Account.where(name: account_names).sum("TRY_PARSE(REPLACE(vesting_shares, ' VESTS', '') AS float)")
|
362
|
+
when :golos then "Query not supported. No database for Golos."
|
363
|
+
when :test then "Query not supported. No database for Testnet."
|
368
364
|
end
|
369
365
|
end
|
370
366
|
|
data/lib/cosgrove/support.rb
CHANGED
@@ -5,8 +5,8 @@ module Cosgrove
|
|
5
5
|
include ActionView::Helpers::DateHelper
|
6
6
|
|
7
7
|
def suggest_account_name(account_name)
|
8
|
-
|
9
|
-
guesses =
|
8
|
+
pattern = account_name.chars.each.map{ |c| c }.join('%')
|
9
|
+
guesses = SteemApi::Account.where("name LIKE '%#{pattern}%'").pluck(:name)
|
10
10
|
|
11
11
|
if guesses.any?
|
12
12
|
guesses.sample
|
@@ -28,41 +28,9 @@ module Cosgrove
|
|
28
28
|
help.join
|
29
29
|
end
|
30
30
|
|
31
|
-
def mongo_behind_warning(event)
|
32
|
-
elapse = -1
|
33
|
-
|
34
|
-
begin
|
35
|
-
message = []
|
36
|
-
|
37
|
-
if (blocks = head_block_number(:steem) - steem_data_head_block_number) > 1200
|
38
|
-
elapse = blocks * 3
|
39
|
-
message << "Mongo is behind by #{time_ago_in_words(elapse.seconds.ago)}."
|
40
|
-
else
|
41
|
-
0
|
42
|
-
end
|
43
|
-
|
44
|
-
if message.size > 0
|
45
|
-
event.respond message.join(' ')
|
46
|
-
end
|
47
|
-
rescue => e
|
48
|
-
event.respond "Mongo might be behind, but the API is also acting up. Please try again later.\n\n```#{e.inspect}\n```"
|
49
|
-
sleep 15
|
50
|
-
event.respond Cosgrove::SnarkCommands::WITTY.sample
|
51
|
-
end
|
52
|
-
|
53
|
-
elapse
|
54
|
-
end
|
55
|
-
|
56
31
|
def cannot_find_input(event, message_prefix = "Unable to find that.")
|
57
32
|
message = [message_prefix]
|
58
33
|
|
59
|
-
message << if (blocks = head_block_number(:steem) - steem_data_head_block_number) > 86400
|
60
|
-
elapse = blocks * 3
|
61
|
-
" Mongo is behind by #{time_ago_in_words(elapse.seconds.ago)}. Try again later."
|
62
|
-
else
|
63
|
-
" Mongo might be behind or this is not a valid input."
|
64
|
-
end
|
65
|
-
|
66
34
|
event.respond message.join(' ')
|
67
35
|
end
|
68
36
|
|
@@ -82,7 +50,7 @@ module Cosgrove
|
|
82
50
|
end
|
83
51
|
|
84
52
|
post = case chain
|
85
|
-
when :steem then
|
53
|
+
when :steem then SteemApi::Comment.where(author: author_name, permlink: permlink).last
|
86
54
|
when :golos then GolosCloud::Comment.where(author: author_name, permlink: permlink).last
|
87
55
|
end
|
88
56
|
|
@@ -111,16 +79,18 @@ module Cosgrove
|
|
111
79
|
"**#{age}** old"
|
112
80
|
end
|
113
81
|
|
114
|
-
|
115
|
-
|
116
|
-
|
82
|
+
active_votes = SteemApi::Tx::Vote.where(author: post.author, permlink: post.permlink)
|
83
|
+
|
84
|
+
if active_votes.any?
|
85
|
+
upvotes = active_votes.map{ |v| v if v.weight > 0 }.compact.count
|
86
|
+
downvotes = active_votes.map{ |v| v if v.weight < 0 }.compact.count
|
117
87
|
netvotes = upvotes - downvotes
|
118
88
|
details << "Net votes: #{netvotes}"
|
119
89
|
|
120
90
|
# Only append this detail of the post less than an hour old.
|
121
91
|
if created > 1.hour.ago
|
122
92
|
votes = case chain
|
123
|
-
when :steem then
|
93
|
+
when :steem then SteemApi::Tx::Vote.where('timestamp > ?', post.created)
|
124
94
|
when :golos then GolosCloud::Vote.where('timestamp > ?', post.created)
|
125
95
|
end
|
126
96
|
total_votes = votes.count
|
@@ -134,8 +104,8 @@ module Cosgrove
|
|
134
104
|
|
135
105
|
details << "Comments: #{post.children.to_i}"
|
136
106
|
|
137
|
-
page_views = page_views("/#{post.parent_permlink}/@#{post.author}/#{post.permlink}")
|
138
|
-
details << "Views: #{page_views}" if !!page_views
|
107
|
+
# page_views = page_views("/#{post.parent_permlink}/@#{post.author}/#{post.permlink}")
|
108
|
+
# details << "Views: #{page_views}" if !!page_views
|
139
109
|
|
140
110
|
begin
|
141
111
|
event.respond details.join('; ')
|
@@ -153,7 +123,7 @@ module Cosgrove
|
|
153
123
|
raise "Required argument: chain" if chain.nil?
|
154
124
|
|
155
125
|
if chain == :steem
|
156
|
-
account = if (accounts =
|
126
|
+
account = if (accounts = SteemApi::Account.where(name: key)).any?
|
157
127
|
accounts.first
|
158
128
|
end
|
159
129
|
end
|
@@ -206,7 +176,7 @@ module Cosgrove
|
|
206
176
|
'Origin' => 'https://steemit.com'
|
207
177
|
})
|
208
178
|
|
209
|
-
csrf = page.parser.to_html.split('
|
179
|
+
csrf = page.parser.to_html.split(':{"csrf":"').last.split('","new_visit":').first
|
210
180
|
# Uncomment in case views stop showing.
|
211
181
|
# puts "DEBUG: #{csrf}"
|
212
182
|
return unless csrf.size == 36
|
data/lib/cosgrove/upvote_job.rb
CHANGED
@@ -29,7 +29,7 @@ module Cosgrove
|
|
29
29
|
return
|
30
30
|
end
|
31
31
|
|
32
|
-
votes_today =
|
32
|
+
votes_today = SteemApi::Tx::Vote.where(voter: steem_account).today
|
33
33
|
today_count = votes_today.count
|
34
34
|
author_count = votes_today.where(author: author_name).count
|
35
35
|
vote_ratio = if today_count == 0
|
data/lib/cosgrove/utils.rb
CHANGED
@@ -89,14 +89,6 @@ module Cosgrove
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
def steem_data_head_block_number
|
93
|
-
begin
|
94
|
-
SteemData::AccountOperation.order(timestamp: -1).limit(1).first.block
|
95
|
-
rescue
|
96
|
-
-1
|
97
|
-
end
|
98
|
-
end
|
99
|
-
|
100
92
|
def properties(chain)
|
101
93
|
api(chain).get_dynamic_global_properties.result
|
102
94
|
end
|
@@ -149,9 +141,9 @@ module Cosgrove
|
|
149
141
|
offset = offset.to_i
|
150
142
|
|
151
143
|
posts = if op == 'latest'
|
152
|
-
|
144
|
+
SteemApi::Comment.where(depth: 0, author: author.name).order(created: :desc)
|
153
145
|
elsif op == 'first'
|
154
|
-
|
146
|
+
SteemApi::Comment.where(depth: 0, author: author.name).order(created: :asc)
|
155
147
|
else
|
156
148
|
[]
|
157
149
|
end
|
@@ -175,7 +167,7 @@ module Cosgrove
|
|
175
167
|
parent_permlink = options[:parent_permlink]
|
176
168
|
|
177
169
|
post = if chain == :steem
|
178
|
-
posts =
|
170
|
+
posts = SteemApi::Comment.where(depth: 0, author: author_name)
|
179
171
|
posts = posts.where(permlink: permlink) if !!permlink
|
180
172
|
posts = posts.where(parent_permlink: parent_permlink) if !!parent_permlink
|
181
173
|
|
@@ -215,19 +207,11 @@ module Cosgrove
|
|
215
207
|
chain = options[:chain]
|
216
208
|
author_name = options[:author_name]
|
217
209
|
|
218
|
-
author =
|
219
|
-
|
220
|
-
if author.nil?
|
221
|
-
author = begin
|
222
|
-
SteemApi::Account.where(name: author_name).last
|
223
|
-
rescue => e
|
224
|
-
puts e
|
225
|
-
end
|
226
|
-
end
|
210
|
+
author = SteemApi::Account.where(name: author_name).first
|
227
211
|
|
228
212
|
if author.nil?
|
229
213
|
author = api(chain).get_accounts([author_name]) do |accounts, errors|
|
230
|
-
accounts.
|
214
|
+
accounts.first
|
231
215
|
end
|
232
216
|
end
|
233
217
|
|
@@ -242,8 +226,9 @@ module Cosgrove
|
|
242
226
|
|
243
227
|
op = case chain
|
244
228
|
when :steem
|
245
|
-
transfers =
|
246
|
-
where(
|
229
|
+
transfers = SteemApi::Tx::Transfer.
|
230
|
+
where(from: from, to: steem_account).
|
231
|
+
where("memo LIKE ?", "%#{memo_key}%")
|
247
232
|
|
248
233
|
if transfers.any?
|
249
234
|
transfers.last
|
@@ -261,8 +246,8 @@ module Cosgrove
|
|
261
246
|
end
|
262
247
|
|
263
248
|
if op.nil?
|
264
|
-
# Fall back to RPC. The transaction is so new,
|
265
|
-
# yet,
|
249
|
+
# Fall back to RPC. The transaction is so new, SteemApi hasn't seen it
|
250
|
+
# yet, SteemApi is behind, or there is no such transfer.
|
266
251
|
|
267
252
|
api(chain).get_account_history(steem_account, -1, 10000) do |history, error|
|
268
253
|
if !!error
|
data/lib/cosgrove/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cosgrove
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.4.0pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Anthony Martin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -76,20 +76,20 @@ dependencies:
|
|
76
76
|
requirements:
|
77
77
|
- - "~>"
|
78
78
|
- !ruby/object:Gem::Version
|
79
|
-
version: '5.
|
79
|
+
version: '5.10'
|
80
80
|
- - ">="
|
81
81
|
- !ruby/object:Gem::Version
|
82
|
-
version: 5.
|
82
|
+
version: 5.10.3
|
83
83
|
type: :development
|
84
84
|
prerelease: false
|
85
85
|
version_requirements: !ruby/object:Gem::Requirement
|
86
86
|
requirements:
|
87
87
|
- - "~>"
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: '5.
|
89
|
+
version: '5.10'
|
90
90
|
- - ">="
|
91
91
|
- !ruby/object:Gem::Version
|
92
|
-
version: 5.
|
92
|
+
version: 5.10.3
|
93
93
|
- !ruby/object:Gem::Dependency
|
94
94
|
name: minitest-line
|
95
95
|
requirement: !ruby/object:Gem::Requirement
|
@@ -99,7 +99,7 @@ dependencies:
|
|
99
99
|
version: '0.6'
|
100
100
|
- - ">="
|
101
101
|
- !ruby/object:Gem::Version
|
102
|
-
version: 0.6.
|
102
|
+
version: 0.6.4
|
103
103
|
type: :development
|
104
104
|
prerelease: false
|
105
105
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -109,7 +109,7 @@ dependencies:
|
|
109
109
|
version: '0.6'
|
110
110
|
- - ">="
|
111
111
|
- !ruby/object:Gem::Version
|
112
|
-
version: 0.6.
|
112
|
+
version: 0.6.4
|
113
113
|
- !ruby/object:Gem::Dependency
|
114
114
|
name: webmock
|
115
115
|
requirement: !ruby/object:Gem::Requirement
|
@@ -179,7 +179,7 @@ dependencies:
|
|
179
179
|
version: '0.9'
|
180
180
|
- - ">="
|
181
181
|
- !ruby/object:Gem::Version
|
182
|
-
version: 0.9.
|
182
|
+
version: 0.9.16
|
183
183
|
type: :development
|
184
184
|
prerelease: false
|
185
185
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -189,47 +189,27 @@ dependencies:
|
|
189
189
|
version: '0.9'
|
190
190
|
- - ">="
|
191
191
|
- !ruby/object:Gem::Version
|
192
|
-
version: 0.9.
|
192
|
+
version: 0.9.16
|
193
193
|
- !ruby/object:Gem::Dependency
|
194
194
|
name: radiator
|
195
195
|
requirement: !ruby/object:Gem::Requirement
|
196
196
|
requirements:
|
197
197
|
- - "~>"
|
198
198
|
- !ruby/object:Gem::Version
|
199
|
-
version: '0.
|
200
|
-
- - ">="
|
201
|
-
- !ruby/object:Gem::Version
|
202
|
-
version: 0.3.15
|
203
|
-
type: :runtime
|
204
|
-
prerelease: false
|
205
|
-
version_requirements: !ruby/object:Gem::Requirement
|
206
|
-
requirements:
|
207
|
-
- - "~>"
|
208
|
-
- !ruby/object:Gem::Version
|
209
|
-
version: '0.3'
|
210
|
-
- - ">="
|
211
|
-
- !ruby/object:Gem::Version
|
212
|
-
version: 0.3.15
|
213
|
-
- !ruby/object:Gem::Dependency
|
214
|
-
name: steem_data
|
215
|
-
requirement: !ruby/object:Gem::Requirement
|
216
|
-
requirements:
|
217
|
-
- - "~>"
|
218
|
-
- !ruby/object:Gem::Version
|
219
|
-
version: '0.0'
|
199
|
+
version: '0.4'
|
220
200
|
- - ">="
|
221
201
|
- !ruby/object:Gem::Version
|
222
|
-
version: 0.
|
202
|
+
version: 0.4.3
|
223
203
|
type: :runtime
|
224
204
|
prerelease: false
|
225
205
|
version_requirements: !ruby/object:Gem::Requirement
|
226
206
|
requirements:
|
227
207
|
- - "~>"
|
228
208
|
- !ruby/object:Gem::Version
|
229
|
-
version: '0.
|
209
|
+
version: '0.4'
|
230
210
|
- - ">="
|
231
211
|
- !ruby/object:Gem::Version
|
232
|
-
version: 0.
|
212
|
+
version: 0.4.3
|
233
213
|
- !ruby/object:Gem::Dependency
|
234
214
|
name: steem_api
|
235
215
|
requirement: !ruby/object:Gem::Requirement
|
@@ -310,26 +290,6 @@ dependencies:
|
|
310
290
|
- - ">="
|
311
291
|
- !ruby/object:Gem::Version
|
312
292
|
version: '1.13'
|
313
|
-
- !ruby/object:Gem::Dependency
|
314
|
-
name: mongoid
|
315
|
-
requirement: !ruby/object:Gem::Requirement
|
316
|
-
requirements:
|
317
|
-
- - "~>"
|
318
|
-
- !ruby/object:Gem::Version
|
319
|
-
version: '6.1'
|
320
|
-
- - ">="
|
321
|
-
- !ruby/object:Gem::Version
|
322
|
-
version: 6.1.0
|
323
|
-
type: :runtime
|
324
|
-
prerelease: false
|
325
|
-
version_requirements: !ruby/object:Gem::Requirement
|
326
|
-
requirements:
|
327
|
-
- - "~>"
|
328
|
-
- !ruby/object:Gem::Version
|
329
|
-
version: '6.1'
|
330
|
-
- - ">="
|
331
|
-
- !ruby/object:Gem::Version
|
332
|
-
version: 6.1.0
|
333
293
|
- !ruby/object:Gem::Dependency
|
334
294
|
name: steem-slap
|
335
295
|
requirement: !ruby/object:Gem::Requirement
|
@@ -537,7 +497,6 @@ files:
|
|
537
497
|
- lib/cosgrove/upvote_job.rb
|
538
498
|
- lib/cosgrove/utils.rb
|
539
499
|
- lib/cosgrove/version.rb
|
540
|
-
- mongoid.yml
|
541
500
|
- support/js/screencap.js
|
542
501
|
homepage: https://github.com/steem-third-party/cosgrove
|
543
502
|
licenses:
|
@@ -554,12 +513,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
554
513
|
version: '0'
|
555
514
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
556
515
|
requirements:
|
557
|
-
- - "
|
516
|
+
- - ">"
|
558
517
|
- !ruby/object:Gem::Version
|
559
|
-
version:
|
518
|
+
version: 1.3.1
|
560
519
|
requirements: []
|
561
520
|
rubyforge_project:
|
562
|
-
rubygems_version: 2.
|
521
|
+
rubygems_version: 2.7.7
|
563
522
|
signing_key:
|
564
523
|
specification_version: 4
|
565
524
|
summary: Cosgrove Discord Bo t
|