weeb 0.0.2 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/weeb/api.rb +3 -0
- data/lib/weeb/api/korra.rb +68 -1
- data/lib/weeb/api/shimakaze.rb +92 -1
- data/lib/weeb/data.rb +160 -2
- data/lib/weeb/err.rb +8 -0
- data/lib/weeb/interfaces/client.rb +2 -1
- data/lib/weeb/interfaces/shimakaze.rb +41 -0
- data/lib/weeb/interfaces/toph.rb +4 -4
- data/lib/weeb/ver.rb +1 -1
- metadata +15 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48e8ce683d4a3c5bd5cef4074be39d9e39c39a15e067271d5832cd2163d6d016
|
4
|
+
data.tar.gz: 7b297145af275b2670b67347662b4082122882e19d93aaa7cea930cbcbcb263f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 93c342bdbf155da57880b061eb7d8f349b44682f40b1df9b84ac2f9bc1f75b0d6be0348635321dccdc27aa194ccbf2a988ae27e9c69bef601093f9dab1d6f0a8
|
7
|
+
data.tar.gz: 4f0a455d913de4a60d86246b64307d49f900237f456ae81018425b48cb079f7c6ab3ba5d88393220a0952c5f0c772eeb15b5be1d225909524172c22499764af4
|
data/lib/weeb/api.rb
CHANGED
@@ -9,6 +9,7 @@ module WeebSh
|
|
9
9
|
module API
|
10
10
|
module_function
|
11
11
|
|
12
|
+
# Request an endpoint easily
|
12
13
|
def request(type, *attributes)
|
13
14
|
parse_json(RestClient.send(type, *attributes))
|
14
15
|
rescue RestClient::RequestEntityTooLarge
|
@@ -39,12 +40,14 @@ module WeebSh
|
|
39
40
|
raise e
|
40
41
|
end
|
41
42
|
|
43
|
+
# @!visibility private
|
42
44
|
def format_user_agent(user_agent)
|
43
45
|
user_agent = "#{user_agent['botname']}/#{user_agent['version']}#{"/#{user_agent['env']}" if user_agent['env']}" if user_agent.is_a?(Hash)
|
44
46
|
return nil unless user_agent.is_a?(String) && !user_agent.empty?
|
45
47
|
user_agent
|
46
48
|
end
|
47
49
|
|
50
|
+
# @!visibility private
|
48
51
|
def parse_json(raw)
|
49
52
|
JSON.parse(raw)
|
50
53
|
rescue JSON::ParserError
|
data/lib/weeb/api/korra.rb
CHANGED
@@ -6,7 +6,74 @@ module WeebSh
|
|
6
6
|
# API endpoints for Korra
|
7
7
|
module Korra
|
8
8
|
BASE = '/auto-image'.freeze
|
9
|
-
|
9
|
+
|
10
|
+
module_function
|
11
|
+
|
12
|
+
def discord_status(interface, query)
|
13
|
+
WeebSh::API.request(
|
14
|
+
:get,
|
15
|
+
"#{interface.api_url}#{BASE}/discord-status?#{URI.encode_www_form(query)}",
|
16
|
+
{
|
17
|
+
Authorization: interface.auth,
|
18
|
+
'User-Agent': interface.user_agent
|
19
|
+
}
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def simple(interface, query)
|
24
|
+
WeebSh::API.request(
|
25
|
+
:get,
|
26
|
+
"#{interface.api_url}#{BASE}/generate?#{URI.encode_www_form(query)}",
|
27
|
+
{
|
28
|
+
Authorization: interface.auth,
|
29
|
+
'User-Agent': interface.user_agent
|
30
|
+
}
|
31
|
+
)
|
32
|
+
end
|
33
|
+
|
34
|
+
def license(interface, title, avatar, badges, widgets)
|
35
|
+
WeebSh::API.request(
|
36
|
+
:post,
|
37
|
+
"#{interface.api_url}#{BASE}/license",
|
38
|
+
{
|
39
|
+
title: title,
|
40
|
+
avatar: avatar,
|
41
|
+
badges: badges,
|
42
|
+
widgets: widgets
|
43
|
+
}.to_json,
|
44
|
+
{
|
45
|
+
Authorization: interface.auth,
|
46
|
+
'User-Agent': interface.user_agent
|
47
|
+
}
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
def waifu_insult(interface, url)
|
52
|
+
WeebSh::API.request(
|
53
|
+
:post,
|
54
|
+
"#{interface.api_url}#{BASE}/waifu-insult",
|
55
|
+
{ avatar: url }.to_json,
|
56
|
+
{
|
57
|
+
Authorization: interface.auth,
|
58
|
+
'User-Agent': interface.user_agent
|
59
|
+
}
|
60
|
+
)
|
61
|
+
end
|
62
|
+
|
63
|
+
def love_ship(interface, target1, target2)
|
64
|
+
WeebSh::API.request(
|
65
|
+
:post,
|
66
|
+
"#{interface.api_url}#{BASE}/love-ship",
|
67
|
+
{
|
68
|
+
targetOne: target1,
|
69
|
+
targetTwo: target2
|
70
|
+
}.to_json,
|
71
|
+
{
|
72
|
+
Authorization: interface.auth,
|
73
|
+
'User-Agent': interface.user_agent
|
74
|
+
}
|
75
|
+
)
|
76
|
+
end
|
10
77
|
end
|
11
78
|
end
|
12
79
|
end
|
data/lib/weeb/api/shimakaze.rb
CHANGED
@@ -6,7 +6,98 @@ module WeebSh
|
|
6
6
|
# API endpoints for Shimakaze
|
7
7
|
module Shimakaze
|
8
8
|
BASE = '/reputation'.freeze
|
9
|
-
|
9
|
+
|
10
|
+
module_function
|
11
|
+
|
12
|
+
def get(interface, bot, user)
|
13
|
+
WeebSh::API.request(
|
14
|
+
:get,
|
15
|
+
"#{interface.api_url}#{BASE}/#{bot}/#{user}",
|
16
|
+
{
|
17
|
+
Authorization: interface.auth,
|
18
|
+
'User-Agent': interface.user_agent
|
19
|
+
}
|
20
|
+
)
|
21
|
+
end
|
22
|
+
|
23
|
+
def give(interface, bot, from, to)
|
24
|
+
WeebSh::API.request(
|
25
|
+
:post,
|
26
|
+
"#{interface.api_url}#{BASE}/#{bot}/#{to}",
|
27
|
+
{
|
28
|
+
source_user: from
|
29
|
+
}.to_json,
|
30
|
+
{
|
31
|
+
Authorization: interface.auth,
|
32
|
+
'User-Agent': interface.user_agent
|
33
|
+
}
|
34
|
+
)
|
35
|
+
end
|
36
|
+
|
37
|
+
def reset(interface, bot, user, reset_cooldown = true)
|
38
|
+
WeebSh::API.request(
|
39
|
+
:post,
|
40
|
+
"#{interface.api_url}#{BASE}/#{bot}/#{user}/reset",
|
41
|
+
{
|
42
|
+
cooldown: reset_cooldown
|
43
|
+
}.to_json,
|
44
|
+
{
|
45
|
+
Authorization: interface.auth,
|
46
|
+
'User-Agent': interface.user_agent
|
47
|
+
}
|
48
|
+
)
|
49
|
+
end
|
50
|
+
|
51
|
+
def increase(interface, bot, user, amount)
|
52
|
+
WeebSh::API.request(
|
53
|
+
:post,
|
54
|
+
"#{interface.api_url}#{BASE}/#{bot}/#{user}/increase",
|
55
|
+
{
|
56
|
+
increase: amount
|
57
|
+
}.to_json,
|
58
|
+
{
|
59
|
+
Authorization: interface.auth,
|
60
|
+
'User-Agent': interface.user_agent
|
61
|
+
}
|
62
|
+
)
|
63
|
+
end
|
64
|
+
|
65
|
+
def decrease(interface, bot, user, amount)
|
66
|
+
WeebSh::API.request(
|
67
|
+
:post,
|
68
|
+
"#{interface.api_url}#{BASE}/#{bot}/#{user}/decrease",
|
69
|
+
{
|
70
|
+
decrease: amount
|
71
|
+
}.to_json,
|
72
|
+
{
|
73
|
+
Authorization: interface.auth,
|
74
|
+
'User-Agent': interface.user_agent
|
75
|
+
}
|
76
|
+
)
|
77
|
+
end
|
78
|
+
|
79
|
+
def get_settings(interface)
|
80
|
+
WeebSh::API.request(
|
81
|
+
:get,
|
82
|
+
"#{interface.api_url}#{BASE}/settings",
|
83
|
+
{
|
84
|
+
Authorization: interface.auth,
|
85
|
+
'User-Agent': interface.user_agent
|
86
|
+
}
|
87
|
+
)
|
88
|
+
end
|
89
|
+
|
90
|
+
def set_settings(interface, settings)
|
91
|
+
WeebSh::API.request(
|
92
|
+
:post,
|
93
|
+
settings.to_json,
|
94
|
+
"#{interface.api_url}#{BASE}/settings",
|
95
|
+
{
|
96
|
+
Authorization: interface.auth,
|
97
|
+
'User-Agent': interface.user_agent
|
98
|
+
}
|
99
|
+
)
|
100
|
+
end
|
10
101
|
end
|
11
102
|
end
|
12
103
|
end
|
data/lib/weeb/data.rb
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
require 'weeb/api'
|
2
|
+
require 'time'
|
2
3
|
|
3
4
|
module WeebSh
|
4
5
|
# Mixin for objects with IDs
|
@@ -25,9 +26,10 @@ module WeebSh
|
|
25
26
|
# @return [String] the URL being used for weeb.sh.
|
26
27
|
attr_reader :api_url
|
27
28
|
|
28
|
-
# @param
|
29
|
+
# @param auth [String] the authentication required to use weeb.sh.
|
29
30
|
# @param user_agent [String, Hash] the user agent to use on endpoints.
|
30
31
|
# @param api_url [String] the URL to use when using the weeb.sh API.
|
32
|
+
# @param client [Client] the client this is tied to.
|
31
33
|
def initialize(auth, user_agent = nil, api_url: 'https://api.weeb.sh', client: nil)
|
32
34
|
@user_agent = WeebSh::API.format_user_agent(user_agent)
|
33
35
|
@auth = auth
|
@@ -40,6 +42,7 @@ module WeebSh
|
|
40
42
|
puts "[#{self.class.name}] Your User Agent is not ideal. Please consider adding a user agent to help identify issues easier." if !user_agent.nil? && user_agent.split('/').count < 2
|
41
43
|
end
|
42
44
|
|
45
|
+
# @!visibility private
|
43
46
|
def inspect
|
44
47
|
"#<#{self.class.name} @api_url=#{@api_url.inspect} @user_agent=#{@user_agent.inspect}>"
|
45
48
|
end
|
@@ -67,6 +70,7 @@ module WeebSh
|
|
67
70
|
@url = data['url']
|
68
71
|
end
|
69
72
|
|
73
|
+
# @!visibility private
|
70
74
|
def inspect
|
71
75
|
"#<WeebSh::PreviewImage @url=#{@url.inspect} @type=#{@type.inspect}>"
|
72
76
|
end
|
@@ -131,7 +135,7 @@ module WeebSh
|
|
131
135
|
end
|
132
136
|
|
133
137
|
# Remove a tag to the image
|
134
|
-
# @param
|
138
|
+
# @param tag [String, Tag] the affected tag
|
135
139
|
def remove_tag(tag)
|
136
140
|
@interface.remove_tags_to_image(self, [tag])
|
137
141
|
end
|
@@ -142,6 +146,7 @@ module WeebSh
|
|
142
146
|
end
|
143
147
|
alias_method :remove, :delete
|
144
148
|
|
149
|
+
# @!visibility private
|
145
150
|
def inspect
|
146
151
|
"#<WeebSh::WeebImage @url=#{@url.inspect} @type=#{@type.inspect} @nsfw=#{@nsfw.inspect}>"
|
147
152
|
end
|
@@ -169,8 +174,161 @@ module WeebSh
|
|
169
174
|
@account = data['account']
|
170
175
|
end
|
171
176
|
|
177
|
+
# @!visibility private
|
172
178
|
def inspect
|
173
179
|
"#<WeebSh::Tag @name=#{@name.inspect} @hidden=#{@hidden.inspect} @account=#{@account.inspect}>"
|
174
180
|
end
|
175
181
|
end
|
182
|
+
|
183
|
+
# Represents a user for shimakaze
|
184
|
+
class User
|
185
|
+
include IDObject
|
186
|
+
|
187
|
+
# @return [Integer] the reputation of the user
|
188
|
+
attr_reader :reputation
|
189
|
+
alias_method :rep, :reputation
|
190
|
+
|
191
|
+
# @return [String] the ID of the bot that issues reputation
|
192
|
+
attr_reader :bot_id
|
193
|
+
|
194
|
+
# @return [String] the ID of the account from the token
|
195
|
+
attr_reader :account
|
196
|
+
|
197
|
+
# @return [Array<Time>] the last time(s) this user has given reputation to another user
|
198
|
+
attr_reader :cooldown
|
199
|
+
alias_method :taken_reputation, :cooldown
|
200
|
+
|
201
|
+
# @return [Array<Time>] the last time(s) this user has received reputation from another user
|
202
|
+
attr_reader :given_reputation
|
203
|
+
|
204
|
+
# @return [Integer, nil] the amount to times the user may give reputation
|
205
|
+
attr_reader :available_reputation
|
206
|
+
|
207
|
+
# @return [Array<Time>, nil] the timestamps referring to the remaining cooldown time until the user can give out reputation from now
|
208
|
+
attr_reader :next_available_reputation
|
209
|
+
|
210
|
+
# @!visibility private
|
211
|
+
def initialize(data, interface)
|
212
|
+
@interface = interface
|
213
|
+
patch(data)
|
214
|
+
@available_reputation = data['availableReputation']
|
215
|
+
@next_available_reputation = data['nextAvailableReputation'] ? data['nextAvailableReputation'].map { |t| Time.parse(t) } : nil
|
216
|
+
end
|
217
|
+
|
218
|
+
# Increases the user's reputation
|
219
|
+
# @param amount [Integer] the amount of reputation that will increase
|
220
|
+
# @return [User] the class itself
|
221
|
+
def increase(amount)
|
222
|
+
response = WeebSh::API::Shimakaze.increase(@interface, @bot_id, @id, amount)
|
223
|
+
patch(response['user'])
|
224
|
+
self
|
225
|
+
end
|
226
|
+
|
227
|
+
# Decreases the user's reputation
|
228
|
+
# @param amount [Integer] the amount of reputation that will decrease
|
229
|
+
# @return [User] the class itself
|
230
|
+
def decrease(amount)
|
231
|
+
response = WeebSh::API::Shimakaze.decrease(@interface, @bot_id, @id, amount)
|
232
|
+
patch(response['user'])
|
233
|
+
self
|
234
|
+
end
|
235
|
+
|
236
|
+
# Resets the user
|
237
|
+
# @return [User] the class itself
|
238
|
+
def reset
|
239
|
+
response = WeebSh::API::Shimakaze.reset(@interface, @bot_id, @id)
|
240
|
+
patch(response['user'])
|
241
|
+
self
|
242
|
+
end
|
243
|
+
|
244
|
+
# Gives reputation to another user
|
245
|
+
# @Param user [User, String, #resolve_id] the user to give reputation to
|
246
|
+
# @return [User] the class itself
|
247
|
+
def give(user)
|
248
|
+
user_id = user.resolve_id if user.respond_to?(:resolve_id)
|
249
|
+
response = API::Shimakaze.give(@interface, @bot_id, @id, user_id || user)
|
250
|
+
patch(response['sourceUser'])
|
251
|
+
user.patch(response['targetUser']) if user.is_a?(User)
|
252
|
+
self
|
253
|
+
end
|
254
|
+
|
255
|
+
# Recieves reputation to another user
|
256
|
+
# @Param user [User, String, #resolve_id] the user to get reputation from
|
257
|
+
# @return [User] the class itself
|
258
|
+
def recieve(user)
|
259
|
+
user_id = user.resolve_id if user.respond_to?(:resolve_id)
|
260
|
+
response = API::Shimakaze.give(@interface, @bot_id, user_id || user, @id)
|
261
|
+
patch(response['targetUser'])
|
262
|
+
user.patch(response['sourceUser']) if user.is_a?(User)
|
263
|
+
self
|
264
|
+
end
|
265
|
+
|
266
|
+
# @!visibility private
|
267
|
+
def patch(data)
|
268
|
+
@reputation = data['reputation']
|
269
|
+
@id = data['userId']
|
270
|
+
@bot_id = data['botId']
|
271
|
+
@account = data['account']
|
272
|
+
@cooldown = data['cooldown'].map { |t| Time.parse(t) }
|
273
|
+
@given_reputation = data['givenReputation'].map { |t| Time.parse(t) }
|
274
|
+
@available_reputation = data['availableReputation'] if data['availableReputation'].nil?
|
275
|
+
@next_available_reputation = data['nextAvailableReputation'].map { |t| Time.parse(t) } if data['nextAvailableReputation'].nil?
|
276
|
+
end
|
277
|
+
|
278
|
+
# @!visibility private
|
279
|
+
def inspect
|
280
|
+
"#<WeebSh::User @reputation=#{@reputation.inspect} @id=#{@id.inspect} @bot_id=#{@bot_id.inspect}>"
|
281
|
+
end
|
282
|
+
end
|
283
|
+
|
284
|
+
# Represents a reputation settings object for shimakaze
|
285
|
+
class ReputationSettings
|
286
|
+
include IDObject
|
287
|
+
|
288
|
+
# @return [Integer] the number of reputations a user may give out per cooldown
|
289
|
+
attr_accessor :reputation_per_day
|
290
|
+
alias_method :rep_per_day, :reputation_per_day
|
291
|
+
|
292
|
+
# @return [Integer] the maximum reputation a user may receive
|
293
|
+
attr_accessor :max_reputation
|
294
|
+
alias_method :max_rep, :max_reputation
|
295
|
+
|
296
|
+
# @return [Integer] the maximum reputation a user may receive per day
|
297
|
+
attr_accessor :max_reputation_per_day
|
298
|
+
alias_method :max_rep_per_day, :max_reputation_per_day
|
299
|
+
|
300
|
+
# @return [Integer] the cooldown per reputation, this is set to time in seconds
|
301
|
+
attr_accessor :reputation_cooldown
|
302
|
+
alias_method :rep_cooldown, :reputation_cooldown
|
303
|
+
|
304
|
+
# @return [String, nil] the ID of the account from the token
|
305
|
+
attr_accessor :account
|
306
|
+
|
307
|
+
# @!visibility private
|
308
|
+
def initialize(data, interface)
|
309
|
+
@interface = interface
|
310
|
+
@reputation_per_day = data['reputationPerDay']
|
311
|
+
@max_reputation = data['maximumReputation']
|
312
|
+
@max_reputation_per_day = data['maximumReputationReceivedDay']
|
313
|
+
@reputation_cooldown = data['reputationCooldown']
|
314
|
+
@account = data['account']
|
315
|
+
end
|
316
|
+
|
317
|
+
# Save the settings on this object
|
318
|
+
# @return [ReputationSettings] the class itself
|
319
|
+
def save
|
320
|
+
WeebSh::API::Shimakaze.set_settings(@interface, {
|
321
|
+
reputationPerDay: @reputation_per_day,
|
322
|
+
maximumReputation: @max_reputation,
|
323
|
+
maximumReputationReceivedDay: @max_reputation_per_day,
|
324
|
+
reputationCooldown: @reputation_cooldown
|
325
|
+
})
|
326
|
+
self
|
327
|
+
end
|
328
|
+
|
329
|
+
# @!visibility private
|
330
|
+
def inspect
|
331
|
+
"#<WeebSh::ReputationSettings @reputation_per_day=#{@reputation_per_day.inspect} @max_reputation=#{@max_reputation.inspect} @max_reputation_per_day=#{@max_reputation_per_day.inspect} @reputation_cooldown=#{@reputation_cooldown.inspect}>"
|
332
|
+
end
|
333
|
+
end
|
176
334
|
end
|
data/lib/weeb/err.rb
CHANGED
@@ -3,6 +3,7 @@ module WeebSh
|
|
3
3
|
module Err
|
4
4
|
# Raised when a token is invalid or incorrect.
|
5
5
|
class BadAuth < RuntimeError
|
6
|
+
# The default message for the error
|
6
7
|
def message
|
7
8
|
'Token invalid'
|
8
9
|
end
|
@@ -10,6 +11,7 @@ module WeebSh
|
|
10
11
|
|
11
12
|
# Raised when too many files were uploaded.
|
12
13
|
class MissingScope < RuntimeError
|
14
|
+
# The default message for the error
|
13
15
|
def message
|
14
16
|
'Too many files requested!'
|
15
17
|
end
|
@@ -17,6 +19,7 @@ module WeebSh
|
|
17
19
|
|
18
20
|
# Raised when a server error occurs
|
19
21
|
class ServerFail < RuntimeError
|
22
|
+
# The default message for the error
|
20
23
|
def message
|
21
24
|
'Server tried to do a thing and borked!'
|
22
25
|
end
|
@@ -24,6 +27,7 @@ module WeebSh
|
|
24
27
|
|
25
28
|
# Raised when requested file(s) have too much bytes.
|
26
29
|
class TooLarge < RuntimeError
|
30
|
+
# The default message for the error
|
27
31
|
def message
|
28
32
|
'File(s) are too large!'
|
29
33
|
end
|
@@ -31,6 +35,7 @@ module WeebSh
|
|
31
35
|
|
32
36
|
# Raised when an invalid mime type was given.
|
33
37
|
class InvalidMIME < RuntimeError
|
38
|
+
# The default message for the error
|
34
39
|
def message
|
35
40
|
'You gave an unsupported MIME type!'
|
36
41
|
end
|
@@ -38,6 +43,7 @@ module WeebSh
|
|
38
43
|
|
39
44
|
# Raised when trying to add an existing tag to an image
|
40
45
|
class TagExists < RuntimeError
|
46
|
+
# The default message for the error
|
41
47
|
def message
|
42
48
|
'Tags existed already or had no content!'
|
43
49
|
end
|
@@ -45,6 +51,7 @@ module WeebSh
|
|
45
51
|
|
46
52
|
# Raised when trying to interact with a non-existant image
|
47
53
|
class InvalidImage < RuntimeError
|
54
|
+
# The default message for the error
|
48
55
|
def message
|
49
56
|
'Non-existant image!'
|
50
57
|
end
|
@@ -52,6 +59,7 @@ module WeebSh
|
|
52
59
|
|
53
60
|
# Raised when loading a file recieves an error
|
54
61
|
class FileError < RuntimeError
|
62
|
+
# The default message for the error
|
55
63
|
def message
|
56
64
|
'Unknown'
|
57
65
|
end
|
@@ -35,8 +35,9 @@ module WeebSh
|
|
35
35
|
alias_method :settings, :tama
|
36
36
|
|
37
37
|
# Groups all interfaces into one.
|
38
|
-
# @param
|
38
|
+
# @param auth [String] the authentication required to use weeb.sh.
|
39
39
|
# @param user_agent [String, Hash] the user agent to use with requests.
|
40
|
+
# @param api_url [String] the URL to use when using the weeb.sh API.
|
40
41
|
def initialize(auth, user_agent = nil, api_url: 'https://api.weeb.sh')
|
41
42
|
@user_agent = WeebSh::API.format_user_agent(user_agent)
|
42
43
|
@auth = auth
|
@@ -4,5 +4,46 @@ require 'weeb/data'
|
|
4
4
|
module WeebSh
|
5
5
|
# Reputation API
|
6
6
|
class Shimakaze < Interface
|
7
|
+
# Makes a class with your bot ID to do requests easier
|
8
|
+
# @param bot [String] the ID of the bot
|
9
|
+
# @return [ShimakazeBot] the bot class
|
10
|
+
def bot(bot)
|
11
|
+
ShimakazeBot.new(bot, self)
|
12
|
+
end
|
13
|
+
|
14
|
+
# Get's a user
|
15
|
+
# @param bot [String] the ID of the bot
|
16
|
+
# @Param user [User, String, #resolve_id] the user to get
|
17
|
+
# @return [User] the user requested
|
18
|
+
def get(bot, user)
|
19
|
+
user_id = user.resolve_id if user.respond_to?(:resolve_id)
|
20
|
+
response = API::Shimakaze.get(self, bot, user_id || user)
|
21
|
+
user.patch(response['user']) if user.is_a?(User)
|
22
|
+
new User(response['user'], self)
|
23
|
+
end
|
24
|
+
|
25
|
+
# Gets the currentyly used settings
|
26
|
+
# @return [ReputationSettings] the user requested
|
27
|
+
def settings
|
28
|
+
new ReputationSettings(response['settings'], self)
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Bot class for shimakaze
|
33
|
+
class ShimakazeBot
|
34
|
+
include IDObject
|
35
|
+
|
36
|
+
# @!visibility private
|
37
|
+
def initialize(id, interface)
|
38
|
+
@interface = interface
|
39
|
+
@id = id
|
40
|
+
end
|
41
|
+
|
42
|
+
# Get's a user
|
43
|
+
# @Param user [User, String, #resolve_id] the user to get
|
44
|
+
# @return [User] the user requested
|
45
|
+
def get(user)
|
46
|
+
@interface.get(@id, user)
|
47
|
+
end
|
7
48
|
end
|
8
49
|
end
|
data/lib/weeb/interfaces/toph.rb
CHANGED
@@ -99,7 +99,7 @@ module WeebSh
|
|
99
99
|
# @param tags [Array<String, Tag>] the affected tags
|
100
100
|
# @return [WeebImage] Returns the image with the given ID.
|
101
101
|
def add_tags_to_image(image, tags)
|
102
|
-
image = image.resolve_id if
|
102
|
+
image = image.resolve_id if image.respond_to?(:resolve_id)
|
103
103
|
tags = tags.map { |t| t.name if t.is_a(Tag) }
|
104
104
|
WeebImage.new(API::Toph.add_tags_to_image(self, image, tags), self)
|
105
105
|
end
|
@@ -109,7 +109,7 @@ module WeebSh
|
|
109
109
|
# @param tags [Array<String, Tag>] the affected tags
|
110
110
|
# @return [WeebImage] Returns the image with the given ID.
|
111
111
|
def remove_tags_to_image(image, tags)
|
112
|
-
image = image.resolve_id if
|
112
|
+
image = image.resolve_id if image.respond_to?(:resolve_id)
|
113
113
|
tags = tags.map { |t| t.name if t.is_a(Tag) }
|
114
114
|
WeebImage.new(API::Toph.remove_tags_to_image(self, image, tags), self)
|
115
115
|
end
|
@@ -120,7 +120,7 @@ module WeebSh
|
|
120
120
|
# @param hidden [true, false] if true, you can only get back hidden tags you added
|
121
121
|
# @param nsfw [true, false, String] whether or not preview images could be NSFW. Setting this to "only" restricts it to NSFW images.
|
122
122
|
# @param file_type [String] the file type an image is required to be for selection
|
123
|
-
# @param page [
|
123
|
+
# @param page [Integer] the page number of images to use
|
124
124
|
# @param account [String] the account ID to get images from
|
125
125
|
# @return [WeebImage] Returns image that was randomly selected.
|
126
126
|
def list(type: nil, tags: [], hidden: false, nsfw: false, file_type: nil, page: 0, account: nil)
|
@@ -139,5 +139,5 @@ module WeebSh
|
|
139
139
|
end
|
140
140
|
|
141
141
|
# Alias for the class {Toph}
|
142
|
-
|
142
|
+
Images = Toph
|
143
143
|
end
|
data/lib/weeb/ver.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: weeb
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0
|
4
|
+
version: 0.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Snazzah
|
@@ -38,6 +38,20 @@ dependencies:
|
|
38
38
|
- - '='
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: 0.49.1
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: inch
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - '='
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: 0.8.0
|
48
|
+
type: :development
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - '='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 0.8.0
|
41
55
|
- !ruby/object:Gem::Dependency
|
42
56
|
name: rest-client
|
43
57
|
requirement: !ruby/object:Gem::Requirement
|