13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/lita/handlers/lita-tuc.rb', line 13
def tuc(response)
query = response.matches[0][0]
http_response = http.get(
URL + query
)
data = MultiJson.load(http_response.body)
if data['error']
reason = data['error']['message'] || "unknown error"
Lita.logger.warn(
"Error: #{reason}"
)
else
response.reply data['balance']
end
rescue => e
Lita.logger.error("Tuc#balance raised #{e.class}: #{e.message}")
response.reply "Tuc has turned off the internetz, #{e.class} is raising '#{e.message}'"
end
|