ayadn 3.0 → 4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +1 -4
- data/CHANGELOG.md +12 -4
- data/README.md +2 -5
- data/ayadn.gemspec +0 -2
- data/doc/01-index.md +0 -3
- data/doc/02-install.md +0 -4
- data/doc/06-post.md +0 -16
- data/doc/{18-contact.md → 16-contact.md} +0 -0
- data/doc/{19-examples.md → 17-examples.md} +0 -0
- data/doc/18-develop.md +165 -0
- data/lib/ayadn/action.rb +206 -396
- data/lib/ayadn/alias.rb +1 -1
- data/lib/ayadn/annotations.rb +15 -27
- data/lib/ayadn/api.rb +39 -28
- data/lib/ayadn/app.rb +19 -29
- data/lib/ayadn/authorize.rb +22 -13
- data/lib/ayadn/blacklist.rb +6 -19
- data/lib/ayadn/channel_object.rb +75 -0
- data/lib/ayadn/check.rb +19 -11
- data/lib/ayadn/cnx.rb +9 -15
- data/lib/ayadn/databases.rb +15 -27
- data/lib/ayadn/debug.rb +9 -9
- data/lib/ayadn/descriptions.rb +1 -99
- data/lib/ayadn/diagnostics.rb +16 -15
- data/lib/ayadn/endpoints.rb +18 -22
- data/lib/ayadn/errors.rb +1 -1
- data/lib/ayadn/fileops.rb +12 -12
- data/lib/ayadn/filtered_post_object.rb +11 -0
- data/lib/ayadn/ids.rb +0 -3
- data/lib/ayadn/logs.rb +4 -4
- data/lib/ayadn/mark.rb +34 -30
- data/lib/ayadn/nicerank.rb +7 -7
- data/lib/ayadn/nowplaying.rb +8 -22
- data/lib/ayadn/pinboard.rb +8 -12
- data/lib/ayadn/post.rb +18 -18
- data/lib/ayadn/post_object.rb +118 -0
- data/lib/ayadn/preferences_object.rb +290 -0
- data/lib/ayadn/profile.rb +2 -2
- data/lib/ayadn/scroll.rb +58 -67
- data/lib/ayadn/search.rb +22 -15
- data/lib/ayadn/set.rb +93 -83
- data/lib/ayadn/settings.rb +25 -33
- data/lib/ayadn/status.rb +24 -26
- data/lib/ayadn/stream.rb +68 -66
- data/lib/ayadn/stream_object.rb +56 -0
- data/lib/ayadn/switch.rb +2 -2
- data/lib/ayadn/user_object.rb +116 -0
- data/lib/ayadn/version.rb +1 -1
- data/lib/ayadn/view.rb +255 -278
- data/lib/ayadn/workers.rb +172 -174
- data/spec/integration/action_spec.rb +55 -34
- data/spec/mock/ayadn.sqlite +0 -0
- data/spec/unit/annotations_spec.rb +54 -41
- data/spec/unit/api_spec.rb +78 -7
- data/spec/unit/blacklistworkers_spec.rb +92 -20
- data/spec/unit/databases_spec.rb +117 -36
- data/spec/unit/endpoints_spec.rb +82 -10
- data/spec/unit/nicerank_spec.rb +56 -27
- data/spec/unit/post_spec.rb +94 -21
- data/spec/unit/set_spec.rb +141 -210
- data/spec/unit/view_spec.rb +105 -32
- data/spec/unit/workers_spec.rb +143 -52
- metadata +12 -37
- data/doc/16-movie.md +0 -39
- data/doc/17-tvshow.md +0 -46
- data/lib/ayadn/nowwatching.rb +0 -118
- data/lib/ayadn/tvshow.rb +0 -162
data/lib/ayadn/descriptions.rb
CHANGED
@@ -1150,7 +1150,7 @@ module Ayadn
|
|
1150
1150
|
|
1151
1151
|
You can block several users at once:
|
1152
1152
|
|
1153
|
-
`ayadn -
|
1153
|
+
`ayadn -BL @spammer @myex @thickhead`
|
1154
1154
|
\n\n
|
1155
1155
|
USAGE
|
1156
1156
|
end
|
@@ -1305,12 +1305,6 @@ module Ayadn
|
|
1305
1305
|
`ayadn -P wave function -Y https://www.youtube.com/watch?v=Ei8CFin00PY`
|
1306
1306
|
|
1307
1307
|
`ayadn -P wargarbl -V http://vimeo.com/123234345`
|
1308
|
-
|
1309
|
-
Embed a movie poster:
|
1310
|
-
|
1311
|
-
`ayadn -P "I'll be back" -M terminator`
|
1312
|
-
|
1313
|
-
(This is different from the 'movie' command, check the docs.)
|
1314
1308
|
\n\n
|
1315
1309
|
USAGE
|
1316
1310
|
end
|
@@ -1337,12 +1331,6 @@ module Ayadn
|
|
1337
1331
|
`ayadn -W -Y https://www.youtube.com/watch?v=Ei8CFin00PY`
|
1338
1332
|
|
1339
1333
|
`ayadn -W -V http://vimeo.com/123234345`
|
1340
|
-
|
1341
|
-
Embed a movie poster:
|
1342
|
-
|
1343
|
-
`ayadn -W -M terminator`
|
1344
|
-
|
1345
|
-
(This is different from the 'movie' command, check the docs.)
|
1346
1334
|
\n\n
|
1347
1335
|
USAGE
|
1348
1336
|
end
|
@@ -1366,10 +1354,6 @@ module Ayadn
|
|
1366
1354
|
|
1367
1355
|
`ayadn pm @ericd -V http://vimeo.com/123234345`
|
1368
1356
|
|
1369
|
-
Embed a movie poster:
|
1370
|
-
|
1371
|
-
`ayadn pm @ericd -M terminator`
|
1372
|
-
|
1373
1357
|
It enters the writing mode where you will type your message.
|
1374
1358
|
|
1375
1359
|
Ayadn will mark your PM channel as read after running this command.
|
@@ -1410,10 +1394,6 @@ module Ayadn
|
|
1410
1394
|
|
1411
1395
|
`ayadn -C 46217 -V http://vimeo.com/123234345`
|
1412
1396
|
|
1413
|
-
Embed a movie poster:
|
1414
|
-
|
1415
|
-
`ayadn -C 46217 -M terminator`
|
1416
|
-
|
1417
1397
|
It enters the writing mode where you will type your message.
|
1418
1398
|
|
1419
1399
|
Ayadn will mark your PM channel as read after running this command.
|
@@ -1461,12 +1441,6 @@ module Ayadn
|
|
1461
1441
|
`ayadn -R23365251 -Y https://www.youtube.com/watch?v=Ei8CFin00PY`
|
1462
1442
|
|
1463
1443
|
`ayadn -R23365251 -V http://vimeo.com/123234345`
|
1464
|
-
|
1465
|
-
Embed a movie poster:
|
1466
|
-
|
1467
|
-
`ayadn -R23365251 -M terminator`
|
1468
|
-
|
1469
|
-
(This is different from the 'movie' command, check the docs.)
|
1470
1444
|
\n\n
|
1471
1445
|
USAGE
|
1472
1446
|
end
|
@@ -1790,78 +1764,6 @@ module Ayadn
|
|
1790
1764
|
\n\n
|
1791
1765
|
USAGE
|
1792
1766
|
end
|
1793
|
-
def self.nowwatching
|
1794
|
-
<<-USAGE
|
1795
|
-
Create a post from (part of) a movie title. Includes movie poster and IMDb url.
|
1796
|
-
|
1797
|
-
Usage:
|
1798
|
-
|
1799
|
-
`ayadn movie ghost in the shell`
|
1800
|
-
|
1801
|
-
`ayadn -NW beetlejuice`
|
1802
|
-
|
1803
|
-
If the movie is not the one you're looking for, you can specify the 'alt' option to force find an alternative.
|
1804
|
-
|
1805
|
-
This is useful for remakes:
|
1806
|
-
|
1807
|
-
`ayadn -NW solaris`
|
1808
|
-
|
1809
|
-
(gives the 2002 version)
|
1810
|
-
|
1811
|
-
`ayadn -NW solaris --alt`
|
1812
|
-
|
1813
|
-
(gives the 1972 version)
|
1814
|
-
|
1815
|
-
Hashtag:
|
1816
|
-
|
1817
|
-
You can modify the default hashtag with 'set':
|
1818
|
-
|
1819
|
-
`ayadn set movie hashtag movietime`
|
1820
|
-
|
1821
|
-
`ayadn set movie hashtag adnmovieclub`
|
1822
|
-
|
1823
|
-
(default is 'nowwatching')
|
1824
|
-
\n\n
|
1825
|
-
USAGE
|
1826
|
-
end
|
1827
|
-
def self.tvshow
|
1828
|
-
<<-USAGE
|
1829
|
-
Create a post from (part of) a TV show title. Includes show poster and IMDb url.
|
1830
|
-
|
1831
|
-
Usage:
|
1832
|
-
|
1833
|
-
`ayadn tvshow magnum`
|
1834
|
-
|
1835
|
-
`ayadn -TV game of thrones`
|
1836
|
-
|
1837
|
-
If the show is not the one you're looking for, you can specify the 'alt' option to force find an alternative.
|
1838
|
-
|
1839
|
-
`ayadn -TV whose line`
|
1840
|
-
|
1841
|
-
(gives the US version)
|
1842
|
-
|
1843
|
-
`ayadn -TV whose line --alt`
|
1844
|
-
|
1845
|
-
(gives the UK version)
|
1846
|
-
|
1847
|
-
Hashtag:
|
1848
|
-
|
1849
|
-
You can modify the default hashtag with 'set':
|
1850
|
-
|
1851
|
-
`ayadn set tvshow hashtag showtime`
|
1852
|
-
|
1853
|
-
`ayadn set tvshow hashtag tvshow`
|
1854
|
-
|
1855
|
-
(default is 'nowwatching')
|
1856
|
-
|
1857
|
-
Banner:
|
1858
|
-
|
1859
|
-
Use the `--banner` (-b) options to insert a banner instead of a poster:
|
1860
|
-
|
1861
|
-
`ayadn -TV magnum --banner`
|
1862
|
-
\n\n
|
1863
|
-
USAGE
|
1864
|
-
end
|
1865
1767
|
def self.random_posts
|
1866
1768
|
<<-USAGE
|
1867
1769
|
Show random posts from App.net.
|
data/lib/ayadn/diagnostics.rb
CHANGED
@@ -47,7 +47,7 @@ module Ayadn
|
|
47
47
|
|
48
48
|
class CheckBase
|
49
49
|
|
50
|
-
attr_accessor :response, :status
|
50
|
+
attr_accessor :response, :status, :baseURL
|
51
51
|
|
52
52
|
def initialize
|
53
53
|
@status = Status.new
|
@@ -110,7 +110,7 @@ module Ayadn
|
|
110
110
|
begin
|
111
111
|
check_root_api
|
112
112
|
@status.say_header "checking ADN server response"
|
113
|
-
get_response "
|
113
|
+
get_response "#{@baseURL}/config"
|
114
114
|
check_response_code
|
115
115
|
body = JSON.parse(@response.body)
|
116
116
|
if body.blank? || body["data"].blank?
|
@@ -128,12 +128,12 @@ module Ayadn
|
|
128
128
|
def check_root_api
|
129
129
|
@status.say_header("default root API endpoint")
|
130
130
|
api_file = Dir.home + "/ayadn/.api.yml"
|
131
|
-
baseURL = if File.exist?(api_file)
|
131
|
+
@baseURL = if File.exist?(api_file)
|
132
132
|
YAML.load(File.read(api_file))[:root]
|
133
133
|
else
|
134
134
|
"https://api.app.net"
|
135
135
|
end
|
136
|
-
@status.say_green(:url, baseURL)
|
136
|
+
@status.say_green(:url, @baseURL)
|
137
137
|
end
|
138
138
|
end
|
139
139
|
|
@@ -149,7 +149,7 @@ module Ayadn
|
|
149
149
|
def check
|
150
150
|
begin
|
151
151
|
@status.say_header("checking accounts database")
|
152
|
-
if find_active_account
|
152
|
+
if find_active_account
|
153
153
|
users = @db.execute("SELECT * FROM Accounts")
|
154
154
|
if users.blank?
|
155
155
|
@status.say_red(:abort, "no registered Ayadn users")
|
@@ -164,7 +164,7 @@ module Ayadn
|
|
164
164
|
check_paths
|
165
165
|
check_config
|
166
166
|
@status.say_header("checking #{@handle}'s account database")
|
167
|
-
if find_active_tables
|
167
|
+
if find_active_tables
|
168
168
|
check_tables_schemas
|
169
169
|
end
|
170
170
|
end
|
@@ -202,17 +202,17 @@ module Ayadn
|
|
202
202
|
@status.say_info "checking table #{table[0]}"
|
203
203
|
case table[0]
|
204
204
|
when "Bookmarks"
|
205
|
-
break if check_bookmarks(table)
|
205
|
+
break if !check_bookmarks(table)
|
206
206
|
when "Aliases"
|
207
|
-
break if check_aliases(table)
|
207
|
+
break if !check_aliases(table)
|
208
208
|
when "Blacklist"
|
209
|
-
break if check_blacklist(table)
|
209
|
+
break if !check_blacklist(table)
|
210
210
|
when "Users"
|
211
|
-
break if check_users(table)
|
211
|
+
break if !check_users(table)
|
212
212
|
when "Pagination"
|
213
|
-
break if check_pagination(table)
|
213
|
+
break if !check_pagination(table)
|
214
214
|
when "TLIndex"
|
215
|
-
break if check_TLIndex(table)
|
215
|
+
break if !check_TLIndex(table)
|
216
216
|
end
|
217
217
|
end
|
218
218
|
end
|
@@ -350,6 +350,7 @@ module Ayadn
|
|
350
350
|
@status.say_green(:pass, "current user is using default values")
|
351
351
|
else
|
352
352
|
diff.each do |key, value|
|
353
|
+
skip if key == :movie || key == :tvshow # those are deprecated, not missing
|
353
354
|
if value.is_a?(Hash)
|
354
355
|
value.each do |inner_key, inner_value|
|
355
356
|
default = inner_value[0].nil? ? "none" : inner_value[0]
|
@@ -362,10 +363,11 @@ module Ayadn
|
|
362
363
|
end
|
363
364
|
else
|
364
365
|
default = value[0].nil? ? "none" : value[0]
|
365
|
-
|
366
|
+
val = value[1]
|
367
|
+
if val.nil?
|
366
368
|
@status.say_red(:missing, "#{key} - Default: #{default}, Current: none")
|
367
369
|
else
|
368
|
-
@status.say_green(:changed, "#{key} - Default: #{default}, Current: #{
|
370
|
+
@status.say_green(:changed, "#{key} - Default: #{default}, Current: #{val}")
|
369
371
|
end
|
370
372
|
end
|
371
373
|
end
|
@@ -376,7 +378,6 @@ module Ayadn
|
|
376
378
|
def check_id_handle
|
377
379
|
id = @active_account[1]
|
378
380
|
@status.say_green(:id, id)
|
379
|
-
# username = @active_account[0]
|
380
381
|
@handle = @active_account[2]
|
381
382
|
@status.say_green(:username, @handle)
|
382
383
|
end
|
data/lib/ayadn/endpoints.rb
CHANGED
@@ -4,11 +4,7 @@ module Ayadn
|
|
4
4
|
|
5
5
|
attr_accessor :ayadn_callback_url, :base_url, :config_api_url, :posts_url, :users_url, :files_url, :token_url, :channels_url, :pm_url
|
6
6
|
|
7
|
-
# Warning
|
8
|
-
# comment next line
|
9
7
|
require_relative "ids"
|
10
|
-
# uncomment and insert your own URL
|
11
|
-
# CALLBACK_URL = ""
|
12
8
|
|
13
9
|
def initialize
|
14
10
|
@ayadn_callback_url = CALLBACK_URL
|
@@ -65,23 +61,23 @@ module Ayadn
|
|
65
61
|
|
66
62
|
def unified(options)
|
67
63
|
make_options_list(options) do
|
68
|
-
API.build_query({count: Settings.options
|
64
|
+
API.build_query({count: Settings.options.counts.unified})
|
69
65
|
end
|
70
66
|
"#{@posts_url}stream/unified?access_token=#{Settings.user_token}#{@options_list}"
|
71
67
|
end
|
72
68
|
|
73
69
|
def checkins(options)
|
74
70
|
make_options_list(options) do
|
75
|
-
API.build_query({count: Settings.options
|
71
|
+
API.build_query({count: Settings.options.counts.checkins})
|
76
72
|
end
|
77
73
|
"#{@posts_url}stream/explore/checkins?access_token=#{Settings.user_token}#{@options_list}"
|
78
74
|
end
|
79
75
|
|
80
76
|
def global(options)
|
81
77
|
make_options_list(options) do
|
82
|
-
API.build_query({count: Settings.options
|
78
|
+
API.build_query({count: Settings.options.counts.global})
|
83
79
|
end
|
84
|
-
if Settings.global
|
80
|
+
if Settings.global.force
|
85
81
|
"#{@posts_url}stream/global?#{@options_list}"
|
86
82
|
else
|
87
83
|
"#{@posts_url}stream/global?access_token=#{Settings.user_token}#{@options_list}"
|
@@ -90,37 +86,37 @@ module Ayadn
|
|
90
86
|
|
91
87
|
def trending(options)
|
92
88
|
make_options_list(options) do
|
93
|
-
API.build_query({count: Settings.options
|
89
|
+
API.build_query({count: Settings.options.counts.trending})
|
94
90
|
end
|
95
91
|
"#{@posts_url}stream/explore/trending?access_token=#{Settings.user_token}#{@options_list}"
|
96
92
|
end
|
97
93
|
|
98
94
|
def photos(options)
|
99
95
|
make_options_list(options) do
|
100
|
-
API.build_query({count: Settings.options
|
96
|
+
API.build_query({count: Settings.options.counts.photos})
|
101
97
|
end
|
102
98
|
"#{@posts_url}stream/explore/photos?access_token=#{Settings.user_token}#{@options_list}"
|
103
99
|
end
|
104
100
|
|
105
101
|
def conversations(options)
|
106
102
|
make_options_list(options) do
|
107
|
-
API.build_query({count: Settings.options
|
103
|
+
API.build_query({count: Settings.options.counts.conversations})
|
108
104
|
end
|
109
105
|
"#{@posts_url}stream/explore/conversations?access_token=#{Settings.user_token}#{@options_list}"
|
110
106
|
end
|
111
107
|
|
112
108
|
def mentions(username, options)
|
113
109
|
make_options_list_simple(options) do
|
114
|
-
API.build_query({count: Settings.options
|
110
|
+
API.build_query({count: Settings.options.counts.mentions})
|
115
111
|
end
|
116
112
|
"#{@users_url}#{username}/mentions/?access_token=#{Settings.user_token}#{@options_list}"
|
117
113
|
end
|
118
114
|
|
119
115
|
def posts(username, options)
|
120
116
|
make_options_list_simple(options) do
|
121
|
-
API.build_query({count: Settings.options
|
117
|
+
API.build_query({count: Settings.options.counts.posts})
|
122
118
|
end
|
123
|
-
if Settings.global
|
119
|
+
if Settings.global.force
|
124
120
|
"#{@users_url}#{username}/posts/?#{@options_list}"
|
125
121
|
else
|
126
122
|
"#{@users_url}#{username}/posts/?access_token=#{Settings.user_token}#{@options_list}"
|
@@ -129,7 +125,7 @@ module Ayadn
|
|
129
125
|
|
130
126
|
def whatstarred(username, options)
|
131
127
|
make_options_list_simple(options) do
|
132
|
-
API.build_query({count: Settings.options
|
128
|
+
API.build_query({count: Settings.options.counts.default})
|
133
129
|
end
|
134
130
|
"#{@users_url}#{username}/stars/?access_token=#{Settings.user_token}#{@options_list}"
|
135
131
|
end
|
@@ -148,7 +144,7 @@ module Ayadn
|
|
148
144
|
|
149
145
|
def convo(post_id, options)
|
150
146
|
make_options_list_simple(options) do
|
151
|
-
API.build_query({count: Settings.options
|
147
|
+
API.build_query({count: Settings.options.counts.convo})
|
152
148
|
end
|
153
149
|
"#{@posts_url}#{post_id}/replies/?access_token=#{Settings.user_token}#{@options_list}"
|
154
150
|
end
|
@@ -175,34 +171,34 @@ module Ayadn
|
|
175
171
|
|
176
172
|
def search(words, options)
|
177
173
|
make_options_list_simple(options) do
|
178
|
-
API.build_query({count: Settings.options
|
174
|
+
API.build_query({count: Settings.options.counts.search})
|
179
175
|
end
|
180
176
|
"#{@posts_url}search?text=#{words}&access_token=#{Settings.user_token}#{@options_list}"
|
181
177
|
end
|
182
178
|
|
183
179
|
def search_users words, options
|
184
180
|
make_options_list_simple(options) do
|
185
|
-
API.build_query({count: Settings.options
|
181
|
+
API.build_query({count: Settings.options.counts.search})
|
186
182
|
end
|
187
183
|
"#{@users_url}search?q=#{words}&access_token=#{Settings.user_token}#{@options_list}"
|
188
184
|
end
|
189
185
|
|
190
186
|
def search_annotations anno, options
|
191
187
|
make_options_list_simple(options) do
|
192
|
-
API.build_query({count: Settings.options
|
188
|
+
API.build_query({count: Settings.options.counts.search})
|
193
189
|
end
|
194
190
|
"#{@posts_url}search?annotation_types=#{anno}&access_token=#{Settings.user_token}#{@options_list}"
|
195
191
|
end
|
196
192
|
|
197
193
|
def search_messages channel_id, words, options
|
198
194
|
make_options_list_simple(options) do
|
199
|
-
API.build_query({count: Settings.options
|
195
|
+
API.build_query({count: Settings.options.counts.search})
|
200
196
|
end
|
201
197
|
"#{@channels_url}messages/search?query=#{words}&channel_ids=#{channel_id}&access_token=#{Settings.user_token}#{@options_list}"
|
202
198
|
end
|
203
199
|
|
204
200
|
def search_channels words, options
|
205
|
-
@options_list = API.build_query({count: Settings.options
|
201
|
+
@options_list = API.build_query({count: Settings.options.counts.search})
|
206
202
|
"#{@channels_url}search?q=#{words}&order=popularity&access_token=#{Settings.user_token}#{@options_list}"
|
207
203
|
end
|
208
204
|
|
@@ -220,7 +216,7 @@ module Ayadn
|
|
220
216
|
|
221
217
|
def files_list(options)
|
222
218
|
make_options_list_simple(options) do
|
223
|
-
API.build_query({count: Settings.options
|
219
|
+
API.build_query({count: Settings.options.counts.files})
|
224
220
|
end
|
225
221
|
"#{@users_url}me/files?access_token=#{Settings.user_token}#{@options_list}"
|
226
222
|
end
|
data/lib/ayadn/errors.rb
CHANGED
@@ -19,7 +19,7 @@ module Ayadn
|
|
19
19
|
end
|
20
20
|
Logs.rec.debug "STACK: #{stack}"
|
21
21
|
Logs.rec.error "--END--"
|
22
|
-
thor.say_status :error, "logged in #{Settings.config
|
22
|
+
thor.say_status :error, "logged in #{Settings.config.paths.log}/ayadn.log", :red
|
23
23
|
puts "\n"
|
24
24
|
Debug.err(args[:error], stack)
|
25
25
|
exit
|
data/lib/ayadn/fileops.rb
CHANGED
@@ -3,11 +3,11 @@ module Ayadn
|
|
3
3
|
class FileOps
|
4
4
|
|
5
5
|
def self.cache_list(list, name)
|
6
|
-
File.write(Settings.config
|
6
|
+
File.write(Settings.config.paths.lists + "/.#{name}", list.to_json)
|
7
7
|
end
|
8
8
|
|
9
9
|
def self.cached_list(name)
|
10
|
-
file_path = Settings.config
|
10
|
+
file_path = Settings.config.paths.lists + "/.#{name}"
|
11
11
|
if File.exist?(file_path)
|
12
12
|
data = File.read(file_path)
|
13
13
|
JSON.load(data)
|
@@ -17,35 +17,35 @@ module Ayadn
|
|
17
17
|
end
|
18
18
|
|
19
19
|
def self.save_links(obj, name)
|
20
|
-
File.write(Settings.config
|
20
|
+
File.write(Settings.config.paths.lists + "/#{name}", obj.to_json)
|
21
21
|
end
|
22
22
|
|
23
23
|
def self.save_post(resp)
|
24
|
-
File.write(Settings.config
|
24
|
+
File.write(Settings.config.paths.posts + "/#{resp['data']['id']}.json", resp['data'].to_json)
|
25
25
|
end
|
26
26
|
|
27
27
|
def self.save_message(resp)
|
28
|
-
File.write(Settings.config
|
28
|
+
File.write(Settings.config.paths.messages + "/#{resp['data']['id']}.json", resp['data'].to_json)
|
29
29
|
end
|
30
30
|
|
31
31
|
def self.save_followings_list(list)
|
32
32
|
fg = get_users(list)
|
33
|
-
File.write(Settings.config
|
33
|
+
File.write(Settings.config.paths.lists + "/followings.json", fg.to_json)
|
34
34
|
end
|
35
35
|
|
36
36
|
def self.save_followers_list(list)
|
37
37
|
fr = get_users(list)
|
38
|
-
File.write(Settings.config
|
38
|
+
File.write(Settings.config.paths.lists + "/followers.json", fr.to_json)
|
39
39
|
end
|
40
40
|
|
41
41
|
def self.save_muted_list(list)
|
42
42
|
mt = get_users(list)
|
43
|
-
File.write(Settings.config
|
43
|
+
File.write(Settings.config.paths.lists + "/muted.json", mt.to_json)
|
44
44
|
end
|
45
45
|
|
46
46
|
def self.download_url(name, url)
|
47
47
|
file = CNX.get_response_from(url)
|
48
|
-
File.write(Settings.config
|
48
|
+
File.write(Settings.config.paths.downloads + "/#{name}", file)
|
49
49
|
end
|
50
50
|
|
51
51
|
def self.upload_files files
|
@@ -59,11 +59,11 @@ module Ayadn
|
|
59
59
|
begin
|
60
60
|
case File.extname(file).downcase
|
61
61
|
when ".png"
|
62
|
-
`curl -k -H 'Authorization: BEARER #{token}' #{Settings.config
|
62
|
+
`curl -k -H 'Authorization: BEARER #{token}' #{Settings.config.api.baseURL}/files -F 'type=com.ayadn.files' -F "content=@#{file};type=image/png" -F 'public=true' -X POST`
|
63
63
|
when ".gif"
|
64
|
-
`curl -k -H 'Authorization: BEARER #{token}' #{Settings.config
|
64
|
+
`curl -k -H 'Authorization: BEARER #{token}' #{Settings.config.api.baseURL}/files -F 'type=com.ayadn.files' -F "content=@#{file};type=image/gif" -F 'public=true' -X POST`
|
65
65
|
else #jpg or jpeg or JPG or JPEG, automatically recognized as such
|
66
|
-
`curl -k -H 'Authorization: BEARER #{token}' #{Settings.config
|
66
|
+
`curl -k -H 'Authorization: BEARER #{token}' #{Settings.config.api.baseURL}/files -F 'type=com.ayadn.files' -F "content=@#{file}" -F 'public=true' -X POST`
|
67
67
|
end
|
68
68
|
rescue Errno::ENOENT
|
69
69
|
Status.new.no_curl
|