6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
|
# File 'lib/slack-wrapper/api/bots.rb', line 6
def info(opts={})
if Slack::API::Auth
opts['token'] = Slack::Config.token
uri = URI.parse('https://slack.com/api/bots.info')
req = Net::HTTP::Post::Multipart.new(uri.path, opts)
res = Net::HTTP::new(uri.host, uri.port)
res.use_ssl = true
res.verify_mode = OpenSSL::SSL::VERIFY_NONE
resp = res.start do |http|
http.request(req)
end
false unless resp.code == 200
if JSON.parse(resp.body)['ok']
JSON.parse(resp.body)['bot']
else
Slack::Errors.new(JSON.parse(resp.body))
end
else
Slack::Errors.new({"error" => "not_authed"})
end
end
|