ayadn 0.6.4 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +20 -0
- data/.rspec +2 -0
- data/.travis.yml +17 -0
- data/Gemfile +14 -0
- data/Guardfile +26 -0
- data/LICENSE.txt +22 -0
- data/MANUAL.md +946 -0
- data/README.md +26 -411
- data/Rakefile +6 -0
- data/ayadn.gemspec +39 -0
- data/bin/ayadn +3 -3
- data/lib/ayadn.rb +12 -25
- data/lib/ayadn/action.rb +1121 -0
- data/lib/ayadn/alias.rb +106 -0
- data/lib/ayadn/api.rb +312 -301
- data/lib/ayadn/app.rb +429 -365
- data/lib/ayadn/authorize.rb +127 -28
- data/lib/ayadn/blacklist.rb +116 -0
- data/lib/ayadn/cnx.rb +105 -0
- data/lib/ayadn/databases.rb +110 -0
- data/lib/ayadn/descriptions.rb +1043 -0
- data/lib/ayadn/endpoints.rb +220 -153
- data/lib/ayadn/errors.rb +37 -0
- data/lib/ayadn/extend.rb +4 -10
- data/lib/ayadn/fileops.rb +48 -0
- data/lib/ayadn/logs.rb +32 -0
- data/lib/ayadn/pinboard.rb +46 -35
- data/lib/ayadn/post.rb +229 -212
- data/lib/ayadn/scroll.rb +251 -0
- data/lib/ayadn/set.rb +377 -0
- data/lib/ayadn/settings.rb +195 -0
- data/lib/ayadn/status.rb +226 -165
- data/lib/ayadn/switch.rb +72 -0
- data/lib/ayadn/version.rb +4 -0
- data/lib/ayadn/view.rb +506 -269
- data/lib/ayadn/workers.rb +362 -0
- data/spec/helpers.rb +19 -0
- data/spec/mock/@ericd.json +160 -0
- data/spec/mock/@m.json +45 -0
- data/spec/mock/checkins.json +1856 -0
- data/spec/mock/fwr_@ayadn.json +1077 -0
- data/spec/mock/posted.json +1 -0
- data/spec/mock/stream.json +1 -0
- data/spec/spec_helper.rb +14 -0
- data/spec/unit/api_spec.rb +61 -0
- data/spec/unit/databases_spec.rb +5 -0
- data/spec/unit/descriptions_spec.rb +9 -0
- data/spec/unit/endpoints_spec.rb +35 -0
- data/spec/unit/post_spec.rb +136 -0
- data/spec/unit/status_spec.rb +9 -0
- data/spec/unit/view_spec.rb +119 -0
- data/spec/unit/workers_spec.rb +147 -0
- metadata +216 -40
- data/CHANGELOG.md +0 -250
- data/CONTRIBUTORS.md +0 -5
- data/LICENSE.md +0 -14
- data/lib/ayadn/adn_files.rb +0 -84
- data/lib/ayadn/client-http.rb +0 -226
- data/lib/ayadn/colors.rb +0 -62
- data/lib/ayadn/config.yml +0 -35
- data/lib/ayadn/debug.rb +0 -36
- data/lib/ayadn/files.rb +0 -184
- data/lib/ayadn/get-api.rb +0 -43
- data/lib/ayadn/help.rb +0 -152
- data/lib/ayadn/list.rb +0 -89
- data/lib/ayadn/main.rb +0 -542
- data/lib/ayadn/requires.rb +0 -12
- data/lib/ayadn/skip.rb +0 -27
- data/lib/ayadn/tools.rb +0 -208
- data/lib/ayadn/user-stream.rb +0 -91
- data/lib/ayadn/view-channels.rb +0 -120
- data/lib/ayadn/view-interactions.rb +0 -57
- data/lib/ayadn/view-object.rb +0 -195
- data/lib/experiments.rb +0 -109
data/lib/ayadn/endpoints.rb
CHANGED
@@ -1,154 +1,221 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
# encoding: utf-8
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
2
|
+
module Ayadn
|
3
|
+
class Endpoints
|
4
|
+
|
5
|
+
attr_accessor :ayadn_callback_url, :base_url, :config_api_url, :posts_url, :users_url, :files_url, :token_url, :channels_url, :pm_url
|
6
|
+
|
7
|
+
def initialize
|
8
|
+
@ayadn_callback_url = "http://aya.io/ayadn/auth.html"
|
9
|
+
@base_url = "https://alpha-api.app.net/"
|
10
|
+
@config_api_url = @base_url + "stream/0/config"
|
11
|
+
@posts_url = @base_url + "stream/0/posts/"
|
12
|
+
@users_url = @base_url + "stream/0/users/"
|
13
|
+
@files_url = @base_url + "stream/0/files/"
|
14
|
+
@token_url = @base_url + "stream/0/token/"
|
15
|
+
@channels_url = @base_url + "stream/0/channels/"
|
16
|
+
@pm_url = @channels_url + "pm/messages"
|
17
|
+
end
|
18
|
+
|
19
|
+
def authorize_url
|
20
|
+
"https://account.app.net/oauth/authenticate?client_id=#{Settings::AYADN_CLIENT_ID}&response_type=token&redirect_uri=#{@ayadn_callback_url}&scope=basic,stream,write_post,follow,public_messages,messages,files,update_profile&include_marker=1"
|
21
|
+
end
|
22
|
+
|
23
|
+
def token_info
|
24
|
+
"#{@token_url}?access_token=#{Settings.user_token}"
|
25
|
+
end
|
26
|
+
|
27
|
+
def file(file_id)
|
28
|
+
"#{@files_url}#{file_id}?access_token=#{Settings.user_token}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def files
|
32
|
+
"#{@files_url}?access_token=#{Settings.user_token}"
|
33
|
+
end
|
34
|
+
|
35
|
+
def unified(options)
|
36
|
+
if options[:count] || options[:since_id]
|
37
|
+
@options_list = API.build_query(options)
|
38
|
+
else
|
39
|
+
@options_list = API.build_query({count: Settings.options[:counts][:unified]})
|
40
|
+
end
|
41
|
+
"#{@posts_url}stream/unified?access_token=#{Settings.user_token}#{@options_list}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def checkins(options)
|
45
|
+
if options[:count] || options[:since_id]
|
46
|
+
@options_list = API.build_query(options)
|
47
|
+
else
|
48
|
+
@options_list = API.build_query({count: Settings.options[:counts][:checkins]})
|
49
|
+
end
|
50
|
+
"#{@posts_url}stream/explore/checkins?access_token=#{Settings.user_token}#{@options_list}"
|
51
|
+
end
|
52
|
+
|
53
|
+
def global(options)
|
54
|
+
if options[:count] || options[:since_id]
|
55
|
+
@options_list = API.build_query(options)
|
56
|
+
else
|
57
|
+
@options_list = API.build_query({count: Settings.options[:counts][:global]})
|
58
|
+
end
|
59
|
+
"#{@posts_url}stream/global?access_token=#{Settings.user_token}#{@options_list}"
|
60
|
+
end
|
61
|
+
|
62
|
+
def trending(options)
|
63
|
+
if options[:count] || options[:since_id]
|
64
|
+
@options_list = API.build_query(options)
|
65
|
+
else
|
66
|
+
@options_list = API.build_query({count: Settings.options[:counts][:trending]})
|
67
|
+
end
|
68
|
+
"#{@posts_url}stream/explore/trending?access_token=#{Settings.user_token}#{@options_list}"
|
69
|
+
end
|
70
|
+
|
71
|
+
def photos(options)
|
72
|
+
if options[:count] || options[:since_id]
|
73
|
+
@options_list = API.build_query(options)
|
74
|
+
else
|
75
|
+
@options_list = API.build_query({count: Settings.options[:counts][:photos]})
|
76
|
+
end
|
77
|
+
"#{@posts_url}stream/explore/photos?access_token=#{Settings.user_token}#{@options_list}"
|
78
|
+
end
|
79
|
+
|
80
|
+
def conversations(options)
|
81
|
+
if options[:count] || options[:since_id]
|
82
|
+
@options_list = API.build_query(options)
|
83
|
+
else
|
84
|
+
@options_list = API.build_query({count: Settings.options[:counts][:conversations]})
|
85
|
+
end
|
86
|
+
"#{@posts_url}stream/explore/conversations?access_token=#{Settings.user_token}#{@options_list}"
|
87
|
+
end
|
88
|
+
|
89
|
+
def mentions(username, options)
|
90
|
+
if options[:count]
|
91
|
+
@options_list = API.build_query(options)
|
92
|
+
else
|
93
|
+
@options_list = API.build_query({count: Settings.options[:counts][:mentions]})
|
94
|
+
end
|
95
|
+
"#{@users_url}#{username}/mentions/?access_token=#{Settings.user_token}#{@options_list}"
|
96
|
+
end
|
97
|
+
|
98
|
+
def posts(username, options)
|
99
|
+
if options[:count]
|
100
|
+
@options_list = API.build_query(options)
|
101
|
+
else
|
102
|
+
@options_list = API.build_query({count: Settings.options[:counts][:posts]})
|
103
|
+
end
|
104
|
+
"#{@users_url}#{username}/posts/?access_token=#{Settings.user_token}#{@options_list}"
|
105
|
+
end
|
106
|
+
|
107
|
+
def whatstarred(username, options)
|
108
|
+
if options[:count]
|
109
|
+
@options_list = API.build_query(options)
|
110
|
+
else
|
111
|
+
@options_list = API.build_query({count: Settings.options[:counts][:default]})
|
112
|
+
end
|
113
|
+
"#{@users_url}#{username}/stars/?access_token=#{Settings.user_token}#{@options_list}"
|
114
|
+
end
|
115
|
+
|
116
|
+
def interactions
|
117
|
+
"#{@users_url}me/interactions?access_token=#{Settings.user_token}"
|
118
|
+
end
|
119
|
+
|
120
|
+
def whoreposted(post_id)
|
121
|
+
"#{@posts_url}#{post_id}/reposters/?access_token=#{Settings.user_token}"
|
122
|
+
end
|
123
|
+
|
124
|
+
def whostarred(post_id)
|
125
|
+
"#{@posts_url}#{post_id}/stars/?access_token=#{Settings.user_token}"
|
126
|
+
end
|
127
|
+
|
128
|
+
def convo(post_id, options)
|
129
|
+
if options[:count]
|
130
|
+
@options_list = API.build_query(options)
|
131
|
+
else
|
132
|
+
@options_list = API.build_query({count: Settings.options[:counts][:convo]})
|
133
|
+
end
|
134
|
+
"#{@posts_url}#{post_id}/replies/?access_token=#{Settings.user_token}#{@options_list}"
|
135
|
+
end
|
136
|
+
|
137
|
+
def followings(username, options)
|
138
|
+
"#{@users_url}#{username}/following/?access_token=#{Settings.user_token}&count=#{options[:count]}&before_id=#{options[:before_id]}"
|
139
|
+
end
|
140
|
+
|
141
|
+
def followers(username, options)
|
142
|
+
"#{@users_url}#{username}/followers/?access_token=#{Settings.user_token}&count=#{options[:count]}&before_id=#{options[:before_id]}"
|
143
|
+
end
|
144
|
+
|
145
|
+
def muted(options)
|
146
|
+
"#{@users_url}me/muted/?access_token=#{Settings.user_token}&count=#{options[:count]}&before_id=#{options[:before_id]}"
|
147
|
+
end
|
148
|
+
|
149
|
+
def blocked(options)
|
150
|
+
"#{@users_url}me/blocked/?access_token=#{Settings.user_token}&count=#{options[:count]}&before_id=#{options[:before_id]}"
|
151
|
+
end
|
152
|
+
|
153
|
+
def hashtag(hashtag)
|
154
|
+
"#{@posts_url}tag/#{hashtag}"
|
155
|
+
end
|
156
|
+
|
157
|
+
def search(words, options)
|
158
|
+
if options[:count]
|
159
|
+
@options_list = API.build_query(options)
|
160
|
+
else
|
161
|
+
@options_list = API.build_query({count: Settings.options[:counts][:search]})
|
162
|
+
end
|
163
|
+
"#{@posts_url}search?text=#{words}&access_token=#{Settings.user_token}#{@options_list}"
|
164
|
+
end
|
165
|
+
|
166
|
+
def user(username)
|
167
|
+
"#{@users_url}#{username}?access_token=#{Settings.user_token}&include_user_annotations=1"
|
168
|
+
end
|
169
|
+
|
170
|
+
def single_post(post_id, options)
|
171
|
+
@options_list = API.build_query(options)
|
172
|
+
"#{@posts_url}#{post_id}?access_token=#{Settings.user_token}#{@options_list}"
|
173
|
+
end
|
174
|
+
|
175
|
+
def files_list(options)
|
176
|
+
if options[:count]
|
177
|
+
@options_list = API.build_query(options)
|
178
|
+
else
|
179
|
+
@options_list = API.build_query({count: Settings.options[:counts][:files]})
|
180
|
+
end
|
181
|
+
"#{@users_url}me/files?access_token=#{Settings.user_token}#{@options_list}"
|
182
|
+
end
|
183
|
+
|
184
|
+
def delete_post(post_id)
|
185
|
+
"#{@posts_url}#{post_id}?access_token=#{Settings.user_token}"
|
186
|
+
end
|
187
|
+
|
188
|
+
def follow(username)
|
189
|
+
"#{@users_url}#{username}/follow?access_token=#{Settings.user_token}"
|
190
|
+
end
|
191
|
+
|
192
|
+
def mute(username)
|
193
|
+
"#{@users_url}#{username}/mute?access_token=#{Settings.user_token}"
|
194
|
+
end
|
195
|
+
|
196
|
+
def block(username)
|
197
|
+
"#{@users_url}#{username}/block?access_token=#{Settings.user_token}"
|
198
|
+
end
|
199
|
+
|
200
|
+
def repost(post_id)
|
201
|
+
"#{@posts_url}#{post_id}/repost?access_token=#{Settings.user_token}"
|
202
|
+
end
|
203
|
+
|
204
|
+
def star(post_id)
|
205
|
+
"#{@posts_url}#{post_id}/star?access_token=#{Settings.user_token}"
|
206
|
+
end
|
207
|
+
|
208
|
+
def channels(options)
|
209
|
+
"#{@channels_url}?access_token=#{Settings.user_token}#{API.build_query(options)}"
|
210
|
+
end
|
211
|
+
|
212
|
+
def messages(channel_id, options)
|
213
|
+
"#{@channels_url}#{channel_id}/messages?access_token=#{Settings.user_token}#{API.build_query(options)}"
|
214
|
+
end
|
215
|
+
|
216
|
+
def ayadnlog
|
217
|
+
"#{@channels_url}47348/messages?access_token=#{Settings.user_token}"
|
218
|
+
end
|
219
|
+
|
220
|
+
end
|
221
|
+
end
|
data/lib/ayadn/errors.rb
ADDED
@@ -0,0 +1,37 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Ayadn
|
3
|
+
class Errors
|
4
|
+
def self.global_error(where, args, error)
|
5
|
+
[where, args, error].each do |el|
|
6
|
+
self.detokenize(el)
|
7
|
+
end
|
8
|
+
Logs.rec.error "--BEGIN--"
|
9
|
+
Logs.rec.error "#{error}"
|
10
|
+
Logs.rec.debug "LOCATION: #{where}"
|
11
|
+
Logs.rec.debug "DATA: #{args}" unless args.nil?
|
12
|
+
Logs.rec.debug "STACK: #{caller}"
|
13
|
+
Logs.rec.error "--END--"
|
14
|
+
puts "\n(error logged in #{Settings.config[:paths][:log]}/ayadn.log)\n".color(:blue)
|
15
|
+
#raise error
|
16
|
+
exit
|
17
|
+
end
|
18
|
+
def self.error(status)
|
19
|
+
Logs.rec.error status
|
20
|
+
end
|
21
|
+
def self.warn(warning)
|
22
|
+
Logs.rec.warn warning
|
23
|
+
end
|
24
|
+
def self.info(msg)
|
25
|
+
Logs.rec.info msg
|
26
|
+
end
|
27
|
+
def self.repost(repost, original)
|
28
|
+
Logs.rec.info "Post #{repost} is a repost. Using original: #{original}."
|
29
|
+
end
|
30
|
+
|
31
|
+
private
|
32
|
+
|
33
|
+
def self.detokenize(string)
|
34
|
+
string.to_s.gsub!(/token=[a-zA-Z0-9_-]+/, "token=XXX") unless string.nil?
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/lib/ayadn/extend.rb
CHANGED
@@ -1,9 +1,8 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
1
|
# encoding: utf-8
|
3
2
|
class String
|
4
|
-
|
5
|
-
|
6
|
-
|
3
|
+
def is_integer?
|
4
|
+
self.to_i.to_s == self
|
5
|
+
end
|
7
6
|
end
|
8
7
|
class Integer
|
9
8
|
def to_filesize
|
@@ -13,11 +12,6 @@ class Integer
|
|
13
12
|
'MB' => 1024 * 1024 * 1024,
|
14
13
|
'GB' => 1024 * 1024 * 1024 * 1024,
|
15
14
|
'TB' => 1024 * 1024 * 1024 * 1024 * 1024
|
16
|
-
}.each_pair { |e, s| return "#{(self.to_f / (s / 1024)).round(2)}#{e}" if self < s }
|
15
|
+
}.each_pair { |e, s| return "#{(self.to_f / (s / 1024)).round(2)} #{e}" if self < s }
|
17
16
|
end
|
18
17
|
end
|
19
|
-
class Numeric
|
20
|
-
def percent_of(n)
|
21
|
-
self.to_f / n.to_f * 100.0
|
22
|
-
end
|
23
|
-
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
module Ayadn
|
3
|
+
class FileOps
|
4
|
+
|
5
|
+
def self.save_post(resp)
|
6
|
+
File.write(Settings.config[:paths][:posts] + "/#{resp['data']['id']}.json", resp['data'].to_json)
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.save_message(resp)
|
10
|
+
File.write(Settings.config[:paths][:messages] + "/#{resp['data']['id']}.json", resp['data'].to_json)
|
11
|
+
end
|
12
|
+
|
13
|
+
def self.save_followings_list(list)
|
14
|
+
fg = get_users(list)
|
15
|
+
File.write(Settings.config[:paths][:lists] + "/followings.json", fg.to_json)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.save_followers_list(list)
|
19
|
+
fr = get_users(list)
|
20
|
+
File.write(Settings.config[:paths][:lists] + "/followers.json", fr.to_json)
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.save_muted_list(list)
|
24
|
+
mt = get_users(list)
|
25
|
+
File.write(Settings.config[:paths][:lists] + "/muted.json", mt.to_json)
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.download_url(name, url)
|
29
|
+
file = CNX.get_response_from(url)
|
30
|
+
File.write(Settings.config[:paths][:downloads] + "/#{name}", file)
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.old_ayadn?
|
34
|
+
Dir.exist?(Dir.home + "/ayadn/data")
|
35
|
+
end
|
36
|
+
|
37
|
+
private
|
38
|
+
|
39
|
+
def get_users(list)
|
40
|
+
h = {}
|
41
|
+
list.each do |k,v|
|
42
|
+
h[k] = { username: v[0], name: v[1] }
|
43
|
+
end
|
44
|
+
h
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
end
|