mixin_bot 0.5.1 → 0.5.5
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 +4 -4
- data/lib/mixin_bot/api/attachment.rb +19 -0
- data/lib/mixin_bot/api/message.rb +8 -0
- data/lib/mixin_bot/client.rb +25 -3
- data/lib/mixin_bot/version.rb +1 -1
- data/lib/mixin_bot.rb +3 -0
- metadata +16 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2cbeb9f0b3c598dc54baa15db0115f4cacc9db5ab309f487783937aeb48e6534
|
4
|
+
data.tar.gz: 46b2e055e49ccc417b0f4513f5d60baf0105130e62782c691789eeaa97d0878a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8a4ff5b1e4de11d82a3e996a5bfdec05cfc3768caf38422945a086a3666ab0ee73c0849006279c9627e5aae65c6a747cb1eaf85cb038a8d4bd0913641a10d8a8
|
7
|
+
data.tar.gz: 9b92e8cdeaeccd3e5d1a05c5d5237e3fc175e68187baeb097ed86c9821ce9a95c7f4ab310462c12655e45e018bf4d53d787744b08b7ad5a5e3f90e853deedb5f
|
@@ -21,6 +21,25 @@ module MixinBot
|
|
21
21
|
client.post(path, headers: { 'Authorization': authorization }, json: {})
|
22
22
|
end
|
23
23
|
|
24
|
+
def upload_attachment(file)
|
25
|
+
attachment = create_attachment['data']
|
26
|
+
|
27
|
+
HTTP
|
28
|
+
.timeout(connect: 5, write: 5, read: 5)
|
29
|
+
.request(
|
30
|
+
:put,
|
31
|
+
attachment.delete('upload_url'),
|
32
|
+
{
|
33
|
+
body: file,
|
34
|
+
headers: {
|
35
|
+
'x-amz-acl': 'public-read',
|
36
|
+
'Content-Type': 'application/octet-stream',
|
37
|
+
}
|
38
|
+
})
|
39
|
+
|
40
|
+
attachment
|
41
|
+
end
|
42
|
+
|
24
43
|
def read_attachment(attachment_id)
|
25
44
|
path = format('/attachments/%<id>s', id: attachment_id)
|
26
45
|
access_token ||= access_token('GET', path, '')
|
@@ -276,6 +276,14 @@ module MixinBot
|
|
276
276
|
send_message plain_text(options)
|
277
277
|
end
|
278
278
|
|
279
|
+
def send_image_message(options)
|
280
|
+
send_message plain_image(options)
|
281
|
+
end
|
282
|
+
|
283
|
+
def send_file_message(options)
|
284
|
+
send_message plain_data(options)
|
285
|
+
end
|
286
|
+
|
279
287
|
def send_post_message(options)
|
280
288
|
send_message plain_post(options)
|
281
289
|
end
|
data/lib/mixin_bot/client.rb
CHANGED
@@ -55,13 +55,35 @@ module MixinBot
|
|
55
55
|
# 500 500 Internal Server Error.
|
56
56
|
# 500 7000 Blaze server error.
|
57
57
|
# 500 7001 The blaze operation timeout.
|
58
|
+
# 202 10002 Illegal request paramters.
|
59
|
+
# 202 20117 Insufficient balance。
|
60
|
+
# 202 20118 PIN format error.
|
61
|
+
# 202 20119 PIN error.
|
62
|
+
# 202 20120 Transfer amount is too small.
|
63
|
+
# 202 20121 Authorization code has expired.
|
64
|
+
# 202 20124 Insufficient withdrawal fee.
|
65
|
+
# 202 20125 The transfer has been paid by someone else.
|
66
|
+
# 202 20127 The withdrawal amount is too small.
|
67
|
+
# 202 20131 Withdrawal Memo format error.
|
68
|
+
# 500 30100 The current asset's public chain synchronization error.
|
69
|
+
# 500 30101 Wrong private key.
|
70
|
+
# 500 30102 Wrong withdrawal address.
|
71
|
+
# 500 30103 Insufficient pool.
|
72
|
+
# 500 7000 WebSocket server error.
|
73
|
+
# 500 7001 WebSocket operation timeout.
|
58
74
|
case result['error']['code']
|
59
|
-
when 401
|
75
|
+
when 401, 20121
|
60
76
|
raise UnauthorizedError, errmsg
|
61
|
-
when 403, 20116
|
77
|
+
when 403, 20116, 10002, 429
|
62
78
|
raise ForbiddenError, errmsg
|
63
|
-
when 400, 404,
|
79
|
+
when 400, 404, 10006, 20133, 500, 7000, 7001
|
64
80
|
raise ResponseError, errmsg
|
81
|
+
when 20117
|
82
|
+
raise InsufficientBalanceError, errmsg
|
83
|
+
when 20118, 20119
|
84
|
+
raise PinError, errmsg
|
85
|
+
when 30103
|
86
|
+
raise InsufficientPoolError, errmsg
|
65
87
|
else
|
66
88
|
raise ResponseError, errmsg
|
67
89
|
end
|
data/lib/mixin_bot/version.rb
CHANGED
data/lib/mixin_bot.rb
CHANGED
@@ -31,4 +31,7 @@ module MixinBot
|
|
31
31
|
class ResponseError < StandardError; end
|
32
32
|
class UnauthorizedError < StandardError; end
|
33
33
|
class ForbiddenError < StandardError; end
|
34
|
+
class InsufficientBalanceError < StandardError; end
|
35
|
+
class InsufficientPoolError < StandardError; end
|
36
|
+
class PinError < StandardError; end
|
34
37
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mixin_bot
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.5.
|
4
|
+
version: 0.5.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- an-lee
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-09-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: awesome_print
|
@@ -150,6 +150,20 @@ dependencies:
|
|
150
150
|
- - "~>"
|
151
151
|
- !ruby/object:Gem::Version
|
152
152
|
version: '1.0'
|
153
|
+
- !ruby/object:Gem::Dependency
|
154
|
+
name: fastimage
|
155
|
+
requirement: !ruby/object:Gem::Requirement
|
156
|
+
requirements:
|
157
|
+
- - "~>"
|
158
|
+
- !ruby/object:Gem::Version
|
159
|
+
version: 2.2.5
|
160
|
+
type: :development
|
161
|
+
prerelease: false
|
162
|
+
version_requirements: !ruby/object:Gem::Requirement
|
163
|
+
requirements:
|
164
|
+
- - "~>"
|
165
|
+
- !ruby/object:Gem::Version
|
166
|
+
version: 2.2.5
|
153
167
|
- !ruby/object:Gem::Dependency
|
154
168
|
name: pry
|
155
169
|
requirement: !ruby/object:Gem::Requirement
|