ayadn 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +15 -0
- data/CHANGELOG.md +232 -0
- data/CONTRIBUTORS.md +5 -0
- data/LICENSE.md +14 -0
- data/README.md +489 -0
- data/bin/ayadn +358 -0
- data/config.yml +35 -0
- data/lib/ayadn/adn_files.rb +84 -0
- data/lib/ayadn/api.rb +302 -0
- data/lib/ayadn/authorize.rb +29 -0
- data/lib/ayadn/client-http.rb +226 -0
- data/lib/ayadn/colors.rb +62 -0
- data/lib/ayadn/debug.rb +36 -0
- data/lib/ayadn/endpoints.rb +154 -0
- data/lib/ayadn/extend.rb +23 -0
- data/lib/ayadn/files.rb +184 -0
- data/lib/ayadn/get-api.rb +43 -0
- data/lib/ayadn/help.rb +149 -0
- data/lib/ayadn/list.rb +89 -0
- data/lib/ayadn/main.rb +536 -0
- data/lib/ayadn/pinboard.rb +37 -0
- data/lib/ayadn/post.rb +212 -0
- data/lib/ayadn/requires.rb +12 -0
- data/lib/ayadn/skip.rb +27 -0
- data/lib/ayadn/status.rb +166 -0
- data/lib/ayadn/tools.rb +204 -0
- data/lib/ayadn/user-stream.rb +91 -0
- data/lib/ayadn/view-channels.rb +119 -0
- data/lib/ayadn/view-interactions.rb +57 -0
- data/lib/ayadn/view-object.rb +193 -0
- data/lib/ayadn/view.rb +270 -0
- data/lib/ayadn.rb +24 -0
- data/lib/experiments.rb +109 -0
- metadata +110 -0
@@ -0,0 +1,154 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
class AyaDN
|
4
|
+
|
5
|
+
AYADN_CLIENT_ID = "hFsCGArAjgJkYBHTHbZnUvzTmL4vaLHL"
|
6
|
+
AYADN_CALLBACK_URL = "http://aya.io/ayadn/auth.html"
|
7
|
+
|
8
|
+
BASE_URL = "https://alpha-api.app.net/"
|
9
|
+
|
10
|
+
CONFIG_API_URL = BASE_URL + "stream/0/config"
|
11
|
+
|
12
|
+
POSTS_URL = BASE_URL + "stream/0/posts/"
|
13
|
+
USERS_URL = BASE_URL + "stream/0/users/"
|
14
|
+
FILES_URL = BASE_URL + "stream/0/files/"
|
15
|
+
CHANNELS_URL = BASE_URL + "stream/0/channels/"
|
16
|
+
PM_URL = CHANNELS_URL + "pm/messages"
|
17
|
+
|
18
|
+
class Endpoints
|
19
|
+
def initialize(token)
|
20
|
+
@token = token
|
21
|
+
end
|
22
|
+
def authorize_url
|
23
|
+
"https://account.app.net/oauth/authenticate?client_id=#{AYADN_CLIENT_ID}&response_type=token&redirect_uri=#{AYADN_CALLBACK_URL}&scope=basic stream write_post follow public_messages messages files&include_marker=1"
|
24
|
+
end
|
25
|
+
def global
|
26
|
+
POSTS_URL + "stream/global?access_token=#{@token}&count=#{$tools.config['counts']['global']}"
|
27
|
+
end
|
28
|
+
def unified
|
29
|
+
POSTS_URL + "stream/unified?access_token=#{@token}&count=#{$tools.config['counts']['unified']}"
|
30
|
+
end
|
31
|
+
def unified_streamback
|
32
|
+
POSTS_URL + "stream/unified?access_token=#{@token}&count=#{$tools.config['timeline']['streamback']}"
|
33
|
+
end
|
34
|
+
def single_post(post_id)
|
35
|
+
POSTS_URL + "#{post_id}?access_token=#{@token}"
|
36
|
+
end
|
37
|
+
def explore(stream)
|
38
|
+
case stream
|
39
|
+
when "checkins"
|
40
|
+
POSTS_URL + "stream/explore/checkins?access_token=#{@token}&count=#{$tools.config['counts']['checkins']}"
|
41
|
+
when "trending", "conversations", "photos"
|
42
|
+
POSTS_URL + "stream/explore/#{stream}?access_token=#{@token}&count=#{$tools.config['counts']['explore']}"
|
43
|
+
end
|
44
|
+
end
|
45
|
+
def hashtags(tags)
|
46
|
+
POSTS_URL + "tag/#{tags}"
|
47
|
+
end
|
48
|
+
def who_reposted(post_id)
|
49
|
+
POSTS_URL + "#{post_id}/reposters/?access_token=#{@token}"
|
50
|
+
end
|
51
|
+
def who_starred(post_id)
|
52
|
+
POSTS_URL + "#{post_id}/stars/?access_token=#{@token}"
|
53
|
+
end
|
54
|
+
def replies(post_id)
|
55
|
+
POSTS_URL + "#{post_id}/replies/?access_token=#{@token}"
|
56
|
+
end
|
57
|
+
def star(post_id)
|
58
|
+
POSTS_URL + "#{post_id}/star/?access_token=#{@token}"
|
59
|
+
end
|
60
|
+
def repost(post_id)
|
61
|
+
POSTS_URL + "#{post_id}/repost/?access_token=#{@token}"
|
62
|
+
end
|
63
|
+
def search(words)
|
64
|
+
POSTS_URL + "search?text=#{words}&access_token=#{@token}&count=#{$tools.config['counts']['search']}"
|
65
|
+
end
|
66
|
+
def mentions(username)
|
67
|
+
USERS_URL + "#{username}/mentions/?access_token=#{@token}&count=#{$tools.config['counts']['mentions']}"
|
68
|
+
end
|
69
|
+
def posts(username)
|
70
|
+
USERS_URL + "#{username}/posts/?access_token=#{@token}&count=#{$tools.config['counts']['posts']}"
|
71
|
+
end
|
72
|
+
def user_info(username)
|
73
|
+
USERS_URL + "#{username}/?access_token=#{@token}"
|
74
|
+
end
|
75
|
+
def starred_posts(username)
|
76
|
+
USERS_URL + "#{username}/stars/?access_token=#{@token}&count=#{$tools.config['counts']['starred']}"
|
77
|
+
end
|
78
|
+
def follow(username)
|
79
|
+
USERS_URL + "#{username}/follow/?access_token=#{@token}"
|
80
|
+
end
|
81
|
+
def following(username)
|
82
|
+
USERS_URL + "#{username}/following/?access_token=#{@token}"
|
83
|
+
end
|
84
|
+
def followers(username)
|
85
|
+
USERS_URL + "#{username}/followers/?access_token=#{@token}"
|
86
|
+
end
|
87
|
+
def mute(username)
|
88
|
+
USERS_URL + "#{username}/mute/?access_token=#{@token}"
|
89
|
+
end
|
90
|
+
def muted(username)
|
91
|
+
USERS_URL + "#{username}/muted/?access_token=#{@token}"
|
92
|
+
end
|
93
|
+
def block(username)
|
94
|
+
USERS_URL + "#{username}/block/?access_token=#{@token}"
|
95
|
+
end
|
96
|
+
def blocked(username)
|
97
|
+
USERS_URL + "#{username}/blocked/?access_token=#{@token}"
|
98
|
+
end
|
99
|
+
def interactions
|
100
|
+
USERS_URL + "me/interactions?access_token=#{@token}"
|
101
|
+
end
|
102
|
+
def channels
|
103
|
+
CHANNELS_URL + "?access_token=#{@token}&count=200"
|
104
|
+
end
|
105
|
+
def messages(channel_id)
|
106
|
+
CHANNELS_URL + "#{channel_id}/messages?access_token=#{@token}&count=200"
|
107
|
+
end
|
108
|
+
def get_message(channel_id, message_id)
|
109
|
+
CHANNELS_URL + "#{channel_id}/messages/#{message_id}?access_token=#{@token}"
|
110
|
+
end
|
111
|
+
def files_list
|
112
|
+
USERS_URL + "me/files?access_token=#{@token}"
|
113
|
+
end
|
114
|
+
def get_file(file_id)
|
115
|
+
FILES_URL + "#{file_id}?access_token=#{@token}"
|
116
|
+
end
|
117
|
+
def get_multiple_files(file_ids)
|
118
|
+
FILES_URL + "?ids=#{file_ids}&access_token=#{@token}"
|
119
|
+
end
|
120
|
+
def access_token
|
121
|
+
"access_token=#{@token}"
|
122
|
+
end
|
123
|
+
def include_deleted
|
124
|
+
"&include_deleted=1"
|
125
|
+
end
|
126
|
+
def exclude_deleted
|
127
|
+
"&include_deleted=0"
|
128
|
+
end
|
129
|
+
def include_html
|
130
|
+
"&include_html=1"
|
131
|
+
end
|
132
|
+
def exclude_html
|
133
|
+
"&include_html=0"
|
134
|
+
end
|
135
|
+
def include_directed
|
136
|
+
"&include_directed_posts=1"
|
137
|
+
end
|
138
|
+
def exclude_directed
|
139
|
+
"&include_directed_posts=0"
|
140
|
+
end
|
141
|
+
def include_annotations
|
142
|
+
"&include_annotations=1"
|
143
|
+
end
|
144
|
+
def exclude_annotations
|
145
|
+
"&include_annotations=0"
|
146
|
+
end
|
147
|
+
def base_params
|
148
|
+
"&include_html=0&include_annotations=1&include_deleted=1"
|
149
|
+
end
|
150
|
+
def light_params
|
151
|
+
"&include_html=0&include_annotations=0&include_deleted=0"
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
data/lib/ayadn/extend.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
class String
|
4
|
+
def is_integer?
|
5
|
+
self.to_i.to_s == self
|
6
|
+
end
|
7
|
+
end
|
8
|
+
class Integer
|
9
|
+
def to_filesize
|
10
|
+
{
|
11
|
+
'B' => 1024,
|
12
|
+
'KB' => 1024 * 1024,
|
13
|
+
'MB' => 1024 * 1024 * 1024,
|
14
|
+
'GB' => 1024 * 1024 * 1024 * 1024,
|
15
|
+
'TB' => 1024 * 1024 * 1024 * 1024 * 1024
|
16
|
+
}.each_pair { |e, s| return "#{(self.to_f / (s / 1024)).round(2)}#{e}" if self < s }
|
17
|
+
end
|
18
|
+
end
|
19
|
+
class Numeric
|
20
|
+
def percent_of(n)
|
21
|
+
self.to_f / n.to_f * 100.0
|
22
|
+
end
|
23
|
+
end
|
data/lib/ayadn/files.rb
ADDED
@@ -0,0 +1,184 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'pstore'
|
3
|
+
require 'fileutils'
|
4
|
+
|
5
|
+
# encoding: utf-8
|
6
|
+
class AyaDN
|
7
|
+
class Files
|
8
|
+
def initialize
|
9
|
+
@token_path = $tools.ayadn_configuration[:authorization_path] + "/token"
|
10
|
+
@channels_path = $tools.ayadn_configuration[:messages_path] + "/channels.json"
|
11
|
+
end
|
12
|
+
def users_write(key, value)
|
13
|
+
db = PStore.new($tools.ayadn_configuration[:db_path] + "/users.db")
|
14
|
+
db.transaction do
|
15
|
+
db[key] = value
|
16
|
+
end
|
17
|
+
end
|
18
|
+
def users_read(key)
|
19
|
+
db = PStore.new($tools.ayadn_configuration[:db_path] + "/users.db")
|
20
|
+
db.transaction do
|
21
|
+
@value = db[key]
|
22
|
+
end
|
23
|
+
return @value
|
24
|
+
end
|
25
|
+
def makedir(value)
|
26
|
+
unless Dir.exists? value
|
27
|
+
FileUtils.mkdir_p value
|
28
|
+
end
|
29
|
+
end
|
30
|
+
def get_last_page_id(value)
|
31
|
+
if File.exists?(value)
|
32
|
+
f = File.open(value, "r")
|
33
|
+
last_page_id = f.gets
|
34
|
+
f.close
|
35
|
+
else
|
36
|
+
last_page_id = nil
|
37
|
+
end
|
38
|
+
return last_page_id
|
39
|
+
end
|
40
|
+
def write_last_page_id(value, content)
|
41
|
+
f = File.new(value, "w")
|
42
|
+
f.puts(content)
|
43
|
+
f.close
|
44
|
+
end
|
45
|
+
def save_channel_alias(channel_id, channel_alias)
|
46
|
+
db = PStore.new($tools.ayadn_configuration[:db_path] + "/channels_alias.db")
|
47
|
+
db.transaction do
|
48
|
+
db[channel_alias] = channel_id
|
49
|
+
end
|
50
|
+
end
|
51
|
+
def load_channel_id(channel_alias)
|
52
|
+
db = PStore.new($tools.ayadn_configuration[:db_path] + "/channels_alias.db")
|
53
|
+
db.transaction do
|
54
|
+
@channel_id = db[channel_alias]
|
55
|
+
end
|
56
|
+
return @channel_id
|
57
|
+
end
|
58
|
+
def save_channel_id(value, content)
|
59
|
+
newPrivateChannel = { "#{value}" => "#{content}" }
|
60
|
+
if !File.exists?@channels_path
|
61
|
+
f = File.new(@channels_path, "w")
|
62
|
+
f.puts(newPrivateChannel.to_json)
|
63
|
+
f.close
|
64
|
+
else
|
65
|
+
the_hash = JSON.parse(IO.read(@channels_path)).to_hash
|
66
|
+
the_hash.merge!(newPrivateChannel)
|
67
|
+
f = File.new(@channels_path, "w")
|
68
|
+
f.puts(the_hash.to_json)
|
69
|
+
f.close
|
70
|
+
end
|
71
|
+
end
|
72
|
+
def save_channel_message(params)
|
73
|
+
channel_to_save = { params[:id] => {
|
74
|
+
text: params[:text],
|
75
|
+
username: params[:username],
|
76
|
+
message_date: params[:message_date]
|
77
|
+
}
|
78
|
+
}
|
79
|
+
the_path = $tools.ayadn_configuration[:messages_path] + "/channels_with_recent_message.json"
|
80
|
+
if !File.exists?the_path
|
81
|
+
f = File.new(the_path, "w")
|
82
|
+
f.puts(channel_to_save.to_json)
|
83
|
+
f.close
|
84
|
+
else
|
85
|
+
the_hash = JSON.parse(IO.read(the_path)).to_hash
|
86
|
+
the_hash.merge!(channel_to_save)
|
87
|
+
f = File.new(the_path, "w")
|
88
|
+
f.puts(the_hash.to_json)
|
89
|
+
f.close
|
90
|
+
end
|
91
|
+
end
|
92
|
+
def load_channels_with_messages
|
93
|
+
the_path = $tools.ayadn_configuration[:messages_path] + "/channels_with_recent_message.json"
|
94
|
+
JSON.load(IO.read(the_path)) if File.exists?the_path
|
95
|
+
end
|
96
|
+
def load_channels
|
97
|
+
JSON.load(IO.read(@channels_path)) if File.exists?@channels_path
|
98
|
+
end
|
99
|
+
def auth_read
|
100
|
+
token = IO.read(@token_path) if File.exists?@token_path
|
101
|
+
return token.chomp() if token != nil
|
102
|
+
end
|
103
|
+
def auth_write(content)
|
104
|
+
f = File.new(@token_path, "w")
|
105
|
+
f.puts(content)
|
106
|
+
f.close
|
107
|
+
end
|
108
|
+
def reset_pagination(content = nil, option = nil)
|
109
|
+
if content != nil
|
110
|
+
if option != nil
|
111
|
+
puts "\nResetting #{content} pagination for #{option}.\n".red
|
112
|
+
filePath = $tools.ayadn_configuration[:last_page_id_path] + "/last_page_id-#{content}-#{option}"
|
113
|
+
if File.exists?(filePath)
|
114
|
+
FileUtils.rm_rf(filePath)
|
115
|
+
puts "\nDone!\n\n".green
|
116
|
+
else
|
117
|
+
puts "\nAlready done: no #{content} pagination value for #{option} was found.\n\n".green
|
118
|
+
end
|
119
|
+
else
|
120
|
+
puts "\nResetting the pagination for #{content}.\n".red
|
121
|
+
filePath = $tools.ayadn_configuration[:last_page_id_path] + "/last_page_id-#{content}"
|
122
|
+
if File.exists?(filePath)
|
123
|
+
FileUtils.rm_rf(filePath)
|
124
|
+
puts "\nDone!\n\n".green
|
125
|
+
else
|
126
|
+
puts "\nAlready done: no #{content} pagination value was found.\n\n".green
|
127
|
+
end
|
128
|
+
end
|
129
|
+
else
|
130
|
+
puts "\nResetting all pagination data.\n".red
|
131
|
+
Dir["#{$tools.ayadn_configuration[:last_page_id_path]}/*"].each do |file|
|
132
|
+
FileUtils.rm_rf file
|
133
|
+
end
|
134
|
+
puts "\nDone!\n\n".green
|
135
|
+
end
|
136
|
+
end
|
137
|
+
def reset_credentials
|
138
|
+
FileUtils.rm_rf(@token_path) if File.exists?(@token_path)
|
139
|
+
end
|
140
|
+
def save_post(post_id)
|
141
|
+
makedir($tools.ayadn_configuration[:posts_path])
|
142
|
+
f = File.new($tools.ayadn_configuration[:posts_path] + "/#{post_id}.post", "w")
|
143
|
+
f.puts(AyaDN::API.new(auth_read).getSinglePost(post_id))
|
144
|
+
f.close
|
145
|
+
end
|
146
|
+
def download_file(file_url, new_file_name, token)
|
147
|
+
download_file_path = $tools.ayadn_configuration[:files_path] + "/#{new_file_name}"
|
148
|
+
if !File.exists?download_file_path
|
149
|
+
resp = AyaDN::API.new(token).http_download(file_url)
|
150
|
+
f = File.new(download_file_path, "wb")
|
151
|
+
f.puts(resp.body)
|
152
|
+
f.close
|
153
|
+
puts "File downloaded in ".green + $tools.ayadn_configuration[:files_path].pink + "/#{new_file_name}".brown + "\n\n"
|
154
|
+
else
|
155
|
+
puts "Canceled: ".red + "#{new_file_name} ".pink + "already exists in ".red + "#{$tools.ayadn_configuration[:files_path]}".brown + "\n\n"
|
156
|
+
end
|
157
|
+
end
|
158
|
+
def delete_file(target, token)
|
159
|
+
puts AyaDN::API.new(token).deleteFile(target)
|
160
|
+
end
|
161
|
+
def uploadFiles(file, token)
|
162
|
+
case File.extname(file).downcase
|
163
|
+
when ".png"
|
164
|
+
`curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F "content=@#{file};type=image/png" -X POST`
|
165
|
+
when ".gif"
|
166
|
+
`curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F "content=@#{file};type=image/gif" -X POST`
|
167
|
+
when ".json",".txt",".md",".markdown",".mdown",".html",".css",".scss",".sass",".jade",".rb",".py",".sh",".js",".xml",".csv",".styl",".liquid",".ru","yml",".coffee",".php"
|
168
|
+
`curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F "content=@#{file};type=text/plain" -X POST`
|
169
|
+
when ".zip"
|
170
|
+
`curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F "content=@#{file};type=application/zip" -X POST`
|
171
|
+
when ".rar"
|
172
|
+
`curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F "content=@#{file};type=application/rar" -X POST`
|
173
|
+
when ".mp4"
|
174
|
+
`curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F "content=@#{file};type=video/mp4" -X POST`
|
175
|
+
when ".mov"
|
176
|
+
`curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F "content=@#{file};type=video/quicktime" -X POST`
|
177
|
+
when ".mkv",".mp3",".m4a",".m4v",".wav",".aif",".aiff",".aac",".flac"
|
178
|
+
`curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F "content=@#{file};type=application/octet-stream" -X POST`
|
179
|
+
else
|
180
|
+
`curl -k -H 'Authorization: BEARER #{token}' https://alpha-api.app.net/stream/0/files -F 'type=com.ayadn.files' -F content=@#{file} -X POST`
|
181
|
+
end
|
182
|
+
end
|
183
|
+
end
|
184
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
class AyaDN
|
4
|
+
def configAPI
|
5
|
+
@time_now = DateTime.now
|
6
|
+
api_config_path = $tools.ayadn_configuration[:api_config_path]
|
7
|
+
$files.makedir(api_config_path)
|
8
|
+
file_API = api_config_path + "/config.json"
|
9
|
+
file_timer = api_config_path + "/timer.json"
|
10
|
+
if !File.exists?(file_API)
|
11
|
+
resp = get_api(file_API, file_timer)
|
12
|
+
else
|
13
|
+
f = File.open(file_timer, "r")
|
14
|
+
hash_timer = JSON.parse(f.gets)
|
15
|
+
f.close
|
16
|
+
if DateTime.parse(hash_timer['deadline']) >= @time_now
|
17
|
+
f = File.open(file_API, "r")
|
18
|
+
resp = JSON.parse(f.gets)
|
19
|
+
f.close
|
20
|
+
else
|
21
|
+
resp = get_api(file_API, file_timer)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
$tools.ayadn_configuration[:post_max_length] = resp['data']['post']['text_max_length']
|
25
|
+
$tools.ayadn_configuration[:message_max_length] = resp['data']['message']['text_max_length']
|
26
|
+
end
|
27
|
+
def get_api(file_API, file_timer)
|
28
|
+
resp = @api.getAPIConfig
|
29
|
+
if resp['meta']['code'] == 200
|
30
|
+
f = File.new(file_API, "w")
|
31
|
+
f.puts(resp.to_json)
|
32
|
+
f.close
|
33
|
+
end
|
34
|
+
hash_timer = {
|
35
|
+
checked: @time_now,
|
36
|
+
deadline: @time_now + 1
|
37
|
+
}
|
38
|
+
f = File.new(file_timer, "w")
|
39
|
+
f.puts(hash_timer.to_json)
|
40
|
+
f.close
|
41
|
+
return resp
|
42
|
+
end
|
43
|
+
end
|
data/lib/ayadn/help.rb
ADDED
@@ -0,0 +1,149 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
class AyaDN
|
4
|
+
class Tools
|
5
|
+
def helpScreen
|
6
|
+
help = "USAGE: ".cyan + "ayadn ".pink + "+ " + "optional action ".green + "+ " + "optional target(s) ".green + "+ " + "optional value(s)\n\n".green
|
7
|
+
help << "- " + "without options: ".cyan + "\tdisplay your unified stream\n" #.rjust(50)
|
8
|
+
help << "- " + "write ".green + "+ [Enter key] ".magenta + "\tcreate a post\n" #.rjust(33)
|
9
|
+
help << "- " + "write ".green + "\"your text\" ".brown + "\tcreate a post\n" #.rjust(35)
|
10
|
+
help << "- " + "reply ".green + "PostID ".brown + "\t\treply to a post\n" #.rjust(42)
|
11
|
+
# help << "- " + "delete postID ".green + "to delete a post\n"
|
12
|
+
help << "- " + "pm ".green + "@username ".brown + "\t\tsend a private message\n"
|
13
|
+
help << "- " + "channels ".green + "\t\tdisplay private channels\n"
|
14
|
+
help << "- " + "messages ".green + "channelID ".brown + "\tdisplay private messages\n"
|
15
|
+
help << "- " + "search ".green + "word ".brown + "\t\tsearch for word(s)\n"
|
16
|
+
help << "- " + "tag ".green + "hashtag ".brown + "\t\tsearch for a hashtag\n"
|
17
|
+
# help << "- " + "star/unstar postID ".green + "to star/unstar a post\n"
|
18
|
+
# help << "- " + "repost/unrepost postID ".green + "to repost/unrepost a post\n"
|
19
|
+
# help << "- " + "infos @username/postID ".green + "to display detailed informations on a user or a post\n"
|
20
|
+
# help << "- " + "convo postID ".green + "to display the conversation around a post\n"
|
21
|
+
help << "- " + "posts ".green + "@username ".brown + "\tdisplay a user's posts\n"
|
22
|
+
help << "- " + "mentions ".green + "@username ".brown + "\tdisplay posts mentionning a user\n"
|
23
|
+
# help << "- " + "starred @username/postID ".green + "to display a user's starred posts / who starred a post\n"
|
24
|
+
# help << "- " + "reposted postID ".green + "to display who reposted a post\n"
|
25
|
+
# help << "- " + "interactions ".green + "to display a stream of your interactions\n"
|
26
|
+
help << "- " + "global/trending/checkins/conversations/photos ".green + "\tdisplay a stream\n"
|
27
|
+
# help << "- " + "follow/unfollow @username ".green + "to follow/unfollow a user\n"
|
28
|
+
# help << "- " + "mute/unmute @username ".green + "to mute/unmute a user\n"
|
29
|
+
#help << "- " + "save/load postID ".green + "to save/load a post locally\n"
|
30
|
+
help << "- " + "list/backup followings/followers/muted ".green + "@username/me ".brown + "\tlist/backup users\n"
|
31
|
+
help << "- " + "infos, delete, star/unstar, repost/unrepost, convo, starred, reposted ".green + "PostID\n".brown
|
32
|
+
help << "- " + "infos, starred, follow, unfollow, mute, unmute ".green + "@username\n".brown
|
33
|
+
#help << "- " + "help ".green + "\t\t\tdisplay this screen\n"
|
34
|
+
help << "- " + "help/commands/webhelp".green + "\n\n"
|
35
|
+
#help << "- " + "tip: ".cyan + "some commands have a shortcut: w(rite), r(eply), s(earch), p(osts), m(entions), t(ag), c(onvo), i(nfos), h(elp)\n"
|
36
|
+
help << "- " + "Tip: put 'scroll' before a stream to use the scrolling feature\n\n".cyan
|
37
|
+
help << "Examples:\n\n".cyan
|
38
|
+
help << "ayadn \n"#.green + "(display your Unified stream)\n"
|
39
|
+
help << "ayadn write \n"#.green + "(write a post with a compose window)\n"
|
40
|
+
help << "ayadn write \'@ayadn Posting with AyaDN!\' \n"#.green + "(write a post instantly between double quotes)\n"
|
41
|
+
help << "ayadn reply 14805036 \n"#.green + "(reply to post n°14805036 with a compose window)\n"
|
42
|
+
help << "ayadn tag nowplaying \n"#.green + "(search for hashtag #nowplaying)\n"
|
43
|
+
help << "ayadn star 14805036 \n"#.green + "(star post n°14805036)\n"
|
44
|
+
help << "ayadn checkins \n"#.green + "(display the Checkins stream)\n"
|
45
|
+
help << "ayadn scroll unified \n"
|
46
|
+
help << "ayadn follow @ayadn \n"#.green + "(follow user @ericd)\n"
|
47
|
+
help << "ayadn search ruby,json \n"#.green + "(search for posts with these words)\n"
|
48
|
+
#help << "ayadn list files \n"
|
49
|
+
help << "ayadn backup followings me \n"
|
50
|
+
help << "\n"
|
51
|
+
return help
|
52
|
+
end
|
53
|
+
def list_of_commands
|
54
|
+
commands = "\nList of commands: \n\n".cyan
|
55
|
+
commands << "ayadn\n"
|
56
|
+
commands << "ayadn scroll\n"
|
57
|
+
commands << "ayadn write\n"
|
58
|
+
commands << "ayadn write '@ericd Good morning Eric!'\n"
|
59
|
+
commands << "ayadn reply 18527205\n"
|
60
|
+
commands << "ayadn pm @ericd\n"
|
61
|
+
commands << "ayadn global\n"
|
62
|
+
commands << "ayadn scroll global\n"
|
63
|
+
commands << "ayadn checkins\n"
|
64
|
+
commands << "ayadn scroll checkins\n"
|
65
|
+
commands << "ayadn trending\n"
|
66
|
+
commands << "ayadn scroll trending\n"
|
67
|
+
commands << "ayadn photos\n"
|
68
|
+
commands << "ayadn scroll photos\n"
|
69
|
+
commands << "ayadn conversations\n"
|
70
|
+
commands << "ayadn scroll conversations\n"
|
71
|
+
commands << "ayadn mentions @ericd\n"
|
72
|
+
commands << "ayadn scroll mentions @ericd\n"
|
73
|
+
commands << "ayadn posts @ericd\n"
|
74
|
+
commands << "ayadn scroll posts @ericd\n"
|
75
|
+
commands << "ayadn starred @ericd\n"
|
76
|
+
commands << "ayadn starred 18527205\n"
|
77
|
+
commands << "ayadn reposted 18527205\n"
|
78
|
+
commands << "ayadn infos @ericd\n"
|
79
|
+
commands << "ayadn infos 18527205\n"
|
80
|
+
commands << "ayadn convo 15726105\n"
|
81
|
+
commands << "ayadn tag nowplaying\n"
|
82
|
+
commands << "ayadn follow @ericd\n"
|
83
|
+
commands << "ayadn unfollow @ericd\n"
|
84
|
+
commands << "ayadn mute @ayaio\n"
|
85
|
+
commands << "ayadn unmute @ayaio\n"
|
86
|
+
commands << "ayadn block @spammer\n"
|
87
|
+
commands << "ayadn unblock @spammer\n"
|
88
|
+
commands << "ayadn interactions\n"
|
89
|
+
commands << "ayadn list files\n"
|
90
|
+
commands << "ayadn list files all\n"
|
91
|
+
commands << "ayadn download 286458\n"
|
92
|
+
commands << "ayadn download 286458,286797\n"
|
93
|
+
commands << "ayadn upload /path/to/kitten.jpg\n"
|
94
|
+
commands << "ayadn private 286458\n"
|
95
|
+
commands << "ayadn public 286458\n"
|
96
|
+
commands << "ayadn delete-file 286458\n"
|
97
|
+
commands << "ayadn search ruby\n"
|
98
|
+
commands << "ayadn search ruby,json\n"
|
99
|
+
commands << "ayadn channels\n"
|
100
|
+
commands << "ayadn send 12345\n"
|
101
|
+
commands << "ayadn messages 12345\n"
|
102
|
+
commands << "ayadn messages 12345 all\n"
|
103
|
+
commands << "ayadn alias-channel 12345 channel_name\n"
|
104
|
+
commands << "ayadn messages channel_name\n"
|
105
|
+
commands << "ayadn star 18527205\n"
|
106
|
+
commands << "ayadn unstar 18527205\n"
|
107
|
+
commands << "ayadn repost 18527205\n"
|
108
|
+
commands << "ayadn unrepost 18527205\n"
|
109
|
+
commands << "ayadn quote 18527205\n"
|
110
|
+
commands << "ayadn delete 12345678\n"
|
111
|
+
commands << "ayadn delete-message 12345 23456789\n"
|
112
|
+
commands << "ayadn list muted\n"
|
113
|
+
commands << "ayadn list followings @ericd\n"
|
114
|
+
commands << "ayadn list followers @ericd\n"
|
115
|
+
commands << "ayadn backup muted\n"
|
116
|
+
commands << "ayadn backup followings @ericd\n"
|
117
|
+
commands << "ayadn backup followers @ericd\n"
|
118
|
+
commands << "ayadn save 18527205\n"
|
119
|
+
commands << "ayadn load 18527205\n"
|
120
|
+
commands << "ayadn skip-source add IFTTT\n"
|
121
|
+
commands << "ayadn skip-source remove IFTTT\n"
|
122
|
+
commands << "ayadn skip-source show\n"
|
123
|
+
commands << "ayadn skip-tag add sports\n"
|
124
|
+
commands << "ayadn skip-tag remove sports\n"
|
125
|
+
commands << "ayadn skip-tag show\n"
|
126
|
+
commands << "ayadn skip-mention add username\n"
|
127
|
+
commands << "ayadn skip-mention remove username\n"
|
128
|
+
commands << "ayadn skip-mention show\n"
|
129
|
+
commands << "ayadn pin 16864003 ruby,json\n"
|
130
|
+
commands << "ayadn unified 10\n"
|
131
|
+
commands << "ayadn global 10\n"
|
132
|
+
commands << "ayadn checkins 10\n"
|
133
|
+
commands << "ayadn photos 10\n"
|
134
|
+
commands << "ayadn trending 10\n"
|
135
|
+
commands << "ayadn conversations 10\n"
|
136
|
+
commands << "ayadn mentions @ericd 10\n"
|
137
|
+
commands << "ayadn posts @ericd 10\n"
|
138
|
+
commands << "ayadn starred @ericd 10\n"
|
139
|
+
commands << "ayadn does @ericd follow @ayadn\n"
|
140
|
+
commands << "ayadn reset pagination\n"
|
141
|
+
commands << "ayadn help\n"
|
142
|
+
commands << "ayadn commands\n"
|
143
|
+
commands << "ayadn webhelp\n"
|
144
|
+
commands << "ayadn random\n"
|
145
|
+
commands << "\n"
|
146
|
+
return commands
|
147
|
+
end
|
148
|
+
end
|
149
|
+
end
|
data/lib/ayadn/list.rb
ADDED
@@ -0,0 +1,89 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
3
|
+
class AyaDN
|
4
|
+
def ayadn_list_files(value)
|
5
|
+
with_url = false
|
6
|
+
if value == "all"
|
7
|
+
puts "\nGetting the list of all your files...\n".green
|
8
|
+
beforeID = nil
|
9
|
+
i = 1
|
10
|
+
loop do
|
11
|
+
params = @view.new(@api.getFilesList(beforeID)).showFilesList(with_url, true)
|
12
|
+
beforeID = params[2].last
|
13
|
+
break if beforeID == nil
|
14
|
+
puts params[0]
|
15
|
+
i += 1
|
16
|
+
if params[2].first != nil
|
17
|
+
$tools.countdown(5) unless i == 2
|
18
|
+
print "\r" + (" " * 40) unless i == 2
|
19
|
+
print "\n\nPlease wait, fetching page (".cyan + "#{beforeID}".pink + ")...\n".cyan unless i == 2
|
20
|
+
end
|
21
|
+
end
|
22
|
+
puts "\n"
|
23
|
+
else
|
24
|
+
puts "\nGetting the list of your recent files...\n".green
|
25
|
+
params = @view.new(@api.getFilesList(nil)).showFilesList(with_url, false)
|
26
|
+
puts params[0]
|
27
|
+
end
|
28
|
+
end
|
29
|
+
def fetch_list(list, name, beforeID)
|
30
|
+
case list
|
31
|
+
when "followers"
|
32
|
+
@api.getFollowers(name, beforeID)
|
33
|
+
when "followings"
|
34
|
+
@api.getFollowings(name, beforeID)
|
35
|
+
when "muted"
|
36
|
+
@api.getMuted(name, beforeID)
|
37
|
+
when "blocked"
|
38
|
+
@api.getBlocked(name, beforeID)
|
39
|
+
end
|
40
|
+
end
|
41
|
+
def getList(list, name)
|
42
|
+
beforeID = nil
|
43
|
+
big_hash = {}
|
44
|
+
@progress_indicator = false
|
45
|
+
loop do
|
46
|
+
@hash = fetch_list(list, name, beforeID)
|
47
|
+
users_hash, min_id = @view.new(@hash).buildFollowList
|
48
|
+
big_hash.merge!(users_hash)
|
49
|
+
break if min_id == nil
|
50
|
+
beforeID = min_id
|
51
|
+
end
|
52
|
+
big_hash
|
53
|
+
end
|
54
|
+
|
55
|
+
def ayadnShowList(list, name)
|
56
|
+
puts $status.fetchingList(list)
|
57
|
+
puts $status.showList(list, name)
|
58
|
+
users, number = @view.new(getList(list, name)).showUsers
|
59
|
+
puts "\n"
|
60
|
+
if number == 0
|
61
|
+
puts $status.errorEmptyList
|
62
|
+
exit
|
63
|
+
end
|
64
|
+
puts users
|
65
|
+
puts "Number of users: ".green + " #{number}\n\n".brown
|
66
|
+
end
|
67
|
+
|
68
|
+
def ayadnSaveList(list, name) # to be called with: var = ayadnSaveList("followers", "@ericd")
|
69
|
+
@progress_indicator = false
|
70
|
+
fileURL = $tools.ayadn_configuration[:lists_path] + "/#{name}-#{list}.json"
|
71
|
+
unless Dir.exists?$tools.ayadn_configuration[:lists_path]
|
72
|
+
puts "Creating lists directory in ".green + "#{$tools.ayadn_configuration[:data_path]}".brown + "\n"
|
73
|
+
FileUtils.mkdir_p $tools.ayadn_configuration[:lists_path]
|
74
|
+
end
|
75
|
+
if File.exists?(fileURL)
|
76
|
+
puts "\nYou already saved this list.\n".red
|
77
|
+
puts "Delete the old one and replace with this one? (n/y)\n".red
|
78
|
+
abort("\nCanceled.\n\n".red) unless STDIN.getch == ("y" || "Y")
|
79
|
+
end
|
80
|
+
puts $status.showList(list, name)
|
81
|
+
puts "Please wait...\n".green
|
82
|
+
puts "Saving the list...\n".green
|
83
|
+
f = File.new(fileURL, "w")
|
84
|
+
f.puts(getList(list, name).to_json)
|
85
|
+
f.close
|
86
|
+
puts "\nSuccessfully saved the list.\n\n".green
|
87
|
+
exit
|
88
|
+
end
|
89
|
+
end
|