Checks if Twitter keys are empty
This commit is contained in:
parent
ffa72bb22f
commit
08e5a6c85f
@ -180,4 +180,9 @@ function serialize_to_file(data, file)
|
|||||||
})
|
})
|
||||||
file:write(serialized)
|
file:write(serialized)
|
||||||
file:close()
|
file:close()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Retruns true if the string is empty
|
||||||
|
function string:isempty()
|
||||||
|
return self == nil or self == ''
|
||||||
end
|
end
|
@ -16,16 +16,23 @@ local client = OAuth.new(consumer_key, consumer_secret, {
|
|||||||
|
|
||||||
function run(msg, matches)
|
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"
|
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)
|
local response_code, response_headers, response_status_line, response_body = client:PerformRequest("GET", twitter_url)
|
||||||
print(response_body)
|
|
||||||
local response = json:decode(response_body)
|
local response = json:decode(response_body)
|
||||||
|
|
||||||
print("response = ", response)
|
|
||||||
|
|
||||||
local header = "Tweet from " .. response.user.name .. " (@" .. response.user.screen_name .. ")\n"
|
local header = "Tweet from " .. response.user.name .. " (@" .. response.user.screen_name .. ")\n"
|
||||||
local text = response.text
|
local text = response.text
|
||||||
|
|
||||||
@ -65,6 +72,4 @@ return {
|
|||||||
usage = "",
|
usage = "",
|
||||||
patterns = {"https://twitter.com/[^/]+/status/([0-9]+)"},
|
patterns = {"https://twitter.com/[^/]+/status/([0-9]+)"},
|
||||||
run = run
|
run = run
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in New Issue
Block a user