Checks if Twitter keys are empty

This commit is contained in:
yago 2015-01-06 14:10:26 +01:00
parent ffa72bb22f
commit 08e5a6c85f
2 changed files with 19 additions and 9 deletions

View File

@ -180,4 +180,9 @@ function serialize_to_file(data, file)
})
file:write(serialized)
file:close()
end
-- Retruns true if the string is empty
function string:isempty()
return self == nil or self == ''
end

View File

@ -16,16 +16,23 @@ local client = OAuth.new(consumer_key, consumer_secret, {
function run(msg, matches)
if consumer_key:isempty() then
return "Twitter Consumer Key is empty, write it in plugins/twitter.lua"
end
if consumer_secret:isempty() then
return "Twitter Consumer Secret is empty, write it in plugins/twitter.lua"
end
if access_token:isempty() then
return "Twitter Access Token is empty, write it in plugins/twitter.lua"
end
if access_token_secret:isempty() then
return "Twitter Access Token Secret is empty, write it in plugins/twitter.lua"
end
local twitter_url = "https://api.twitter.com/1.1/statuses/show/" .. matches[1] .. ".json"
print(twitter_url)
local response_code, response_headers, response_status_line, response_body = client:PerformRequest("GET", twitter_url)
print(response_body)
local response = json:decode(response_body)
print("response = ", response)
local header = "Tweet from " .. response.user.name .. " (@" .. response.user.screen_name .. ")\n"
local text = response.text
@ -65,6 +72,4 @@ return {
usage = "",
patterns = {"https://twitter.com/[^/]+/status/([0-9]+)"},
run = run
}
}