12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
# File 'lib/lita/extensions/ship_to_pastebin.rb', line 12
def save_to_pastebin(message, title: "Lita's Wall of Text",
api_key: API_KEY_DEFAULT )
begin
result = Faraday.post PASTEBIN_URL, {
api_dev_key: api_key,
api_paste_name: title,
api_paste_code: message,
api_paste_expire_date: '1D', api_option: 'paste'
}
rescue Faraday::Error => err
raise ConnectionError, err.message
end
if !result.success? || result.body.include?('Bad API')
raise PasteBinError,
"Unable to deal with this Faraday response: [#{result.body}]"
end
result.body
end
|