Sends tweets
This commit is contained in:
parent
a2dd11bc1c
commit
bf82594034
@ -4,9 +4,9 @@
|
||||
"sudo_users": [ 0, 1 ],
|
||||
"values": { },
|
||||
"twitter": {
|
||||
"consumer_key" : "",
|
||||
"consumer_secret" : "",
|
||||
"access_token" : "",
|
||||
"access_token_secret" : ""
|
||||
"consumer_key" : "gO6IYCtgQ6jaDni3dDAg",
|
||||
"consumer_secret" : "ow6bjXfWLO2izVEMIAqbPE9YdSDqQaO9bcwWa3QU",
|
||||
"access_token" : "45872404-ATKqDJDnmR03uuYSa8KKEwnpww21bNdjqox3IbKJ0",
|
||||
"access_token_secret" : "1OcwUGlBmm2YrqJcO5oD3mNaXs1KtBB8TXvDRyFCdxWi1"
|
||||
}
|
||||
}
|
||||
|
34
plugins/twitter_send.lua
Normal file
34
plugins/twitter_send.lua
Normal file
@ -0,0 +1,34 @@
|
||||
local OAuth = require "OAuth"
|
||||
|
||||
local consumer_key = config.twitter.consumer_key
|
||||
local consumer_secret = config.twitter.consumer_secret
|
||||
local access_token = config.twitter.access_token
|
||||
local access_token_secret = config.twitter.access_token_secret
|
||||
|
||||
local client = OAuth.new(consumer_key, consumer_secret, {
|
||||
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
|
||||
})
|
||||
|
||||
function run(msg, matches)
|
||||
|
||||
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 "Error: "..response_code
|
||||
end
|
||||
return "Tweet enviado"
|
||||
end
|
||||
|
||||
return {
|
||||
description = "Sends a tweet",
|
||||
usage = "!tw [text]",
|
||||
patterns = {"!tw (.+)"},
|
||||
run = run
|
||||
}
|
Reference in New Issue
Block a user