2015-04-14 20:23:55 +02:00
|
|
|
do
|
|
|
|
|
|
|
|
local OAuth = require "OAuth"
|
|
|
|
|
2015-04-19 22:27:37 +02:00
|
|
|
local consumer_key = cred_data.tw_consumer_key
|
|
|
|
local consumer_secret = cred_data.tw_consumer_secret
|
|
|
|
local access_token = cred_data.tw_access_token
|
|
|
|
local access_token_secret = cred_data.tw_access_token_secret
|
2015-04-14 20:23:55 +02:00
|
|
|
|
|
|
|
local client = OAuth.new(consumer_key, consumer_secret, {
|
2015-04-19 22:27:37 +02:00
|
|
|
RequestToken = "https://api.twitter.com/oauth/request_token",
|
|
|
|
AuthorizeUser = {"https://api.twitter.com/oauth/authorize", method = "GET"},
|
|
|
|
AccessToken = "https://api.twitter.com/oauth/access_token"
|
|
|
|
}, {
|
|
|
|
OAuthToken = access_token,
|
|
|
|
OAuthTokenSecret = access_token_secret
|
2015-04-14 20:23:55 +02:00
|
|
|
})
|
|
|
|
|
|
|
|
function run(msg, matches)
|
|
|
|
if consumer_key:isempty() then
|
2015-04-19 22:27:37 +02:00
|
|
|
return "Twitter Consumer Key is empty, write it in plugins/twitter_send.lua"
|
2015-04-14 20:23:55 +02:00
|
|
|
end
|
|
|
|
if consumer_secret:isempty() then
|
2015-04-19 22:27:37 +02:00
|
|
|
return "Twitter Consumer Secret is empty, write it in plugins/twitter_send.lua"
|
2015-04-14 20:23:55 +02:00
|
|
|
end
|
|
|
|
if access_token:isempty() then
|
2015-04-19 22:27:37 +02:00
|
|
|
return "Twitter Access Token is empty, write it in plugins/twitter_send.lua"
|
2015-04-14 20:23:55 +02:00
|
|
|
end
|
|
|
|
if access_token_secret:isempty() then
|
2015-04-19 22:27:37 +02:00
|
|
|
return "Twitter Access Token Secret is empty, write it in plugins/twitter_send.lua"
|
2015-04-14 20:23:55 +02:00
|
|
|
end
|
2015-04-19 22:27:37 +02:00
|
|
|
|
|
|
|
local response_code, response_headers, response_status_line, response_body =
|
|
|
|
client:PerformRequest("POST", "https://api.twitter.com/1.1/statuses/update.json", {
|
|
|
|
status = matches[1]
|
|
|
|
})
|
|
|
|
if response_code ~= 200 then
|
|
|
|
return "Fehler: "..response_code
|
|
|
|
end
|
|
|
|
local data = json:decode(response_body)
|
2015-05-11 22:02:03 +02:00
|
|
|
return "Tweet gesendet!"
|
2015-04-14 20:23:55 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return {
|
2015-04-20 18:52:25 +02:00
|
|
|
description = "",
|
2015-04-19 22:27:37 +02:00
|
|
|
usage = "",
|
|
|
|
patterns = {"^/tw (.+)"},
|
|
|
|
run = run,
|
2015-04-14 20:23:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
end
|