From 90f0f782ed6d74e10bc95075783ae66e036afe29 Mon Sep 17 00:00:00 2001 From: Akamaru Date: Sun, 19 Apr 2015 22:27:37 +0200 Subject: [PATCH] some little changes on echo.lua and twitter_send.lua --- plugins/echo.lua | 4 +-- plugins/twitter_send.lua | 58 +++++++++++++++++++--------------------- 2 files changed, 29 insertions(+), 33 deletions(-) diff --git a/plugins/echo.lua b/plugins/echo.lua index 9fb678b..973f665 100644 --- a/plugins/echo.lua +++ b/plugins/echo.lua @@ -6,8 +6,6 @@ end return { description = "Wiederholt euch", usage = "/echo [Satz]", - patterns = { - "^/echo (.*)$" - }, + patterns = {"^/echo (.*)$"}, run = run } diff --git a/plugins/twitter_send.lua b/plugins/twitter_send.lua index 5ae4f7c..3db44f6 100644 --- a/plugins/twitter_send.lua +++ b/plugins/twitter_send.lua @@ -2,53 +2,51 @@ do local OAuth = require "OAuth" -local consumer_key = "" -local consumer_secret = "" -local access_token = "" -local access_token_secret = "" +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 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 + 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) if consumer_key:isempty() then - return "Twitter Consumer Key is empty, write it in plugins/twitter_send.lua" + return "Twitter Consumer Key is empty, write it in plugins/twitter_send.lua" end if consumer_secret:isempty() then - return "Twitter Consumer Secret is empty, write it in plugins/twitter_send.lua" + return "Twitter Consumer Secret is empty, write it in plugins/twitter_send.lua" end if access_token:isempty() then - return "Twitter Access Token is empty, write it in plugins/twitter_send.lua" + return "Twitter Access Token is empty, write it in plugins/twitter_send.lua" end if access_token_secret:isempty() then - return "Twitter Access Token Secret is empty, write it in plugins/twitter_send.lua" + return "Twitter Access Token Secret is empty, write it in plugins/twitter_send.lua" end - - if not is_sudo(msg) then - return "You aren't allowed to send tweets" - end - - 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 sended" + + 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) + return "Tweet gesendet! Sieh ihn dir an: https://twitter.com/TalesOfTelegram/status/"..data.id_str end return { description = "Sends a tweet", - usage = "!tw [text]: Sends the Tweet with the configured accout.", - patterns = {"^!tw (.+)"}, - run = run + usage = "", + patterns = {"^/tw (.+)"}, + run = run, + privileged = true } end \ No newline at end of file