From a103f58697ac6663c0f3f62bebd6d66317fc0685 Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Sat, 16 Jul 2016 13:10:07 +0200 Subject: [PATCH] Twitter: Fix Pattern --- otouto/plugins/twitter.lua | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/otouto/plugins/twitter.lua b/otouto/plugins/twitter.lua index 92175cd..b3a622c 100644 --- a/otouto/plugins/twitter.lua +++ b/otouto/plugins/twitter.lua @@ -27,7 +27,8 @@ function twitter:init(config) end twitter.triggers = { - 'twitter.com/[^/]+/statuse?s?/([0-9]+)' + 'twitter.com/[^/]+/statuse?s?/([0-9]+)', + 'twitter.com/statuse?s?/([0-9]+)' } twitter.doc = [[*Twitter-Link*: Postet Tweet]] end @@ -46,12 +47,13 @@ local client = OAuth.new(consumer_key, consumer_secret, { OAuthTokenSecret = access_token_secret }) -function twitter:action(msg) +function twitter:action(msg, config, matches) - if not msg.text:match('twitter.com/[^/]+/statuse?s?/([0-9]+)') then - return + if not matches[2] then + id = matches[1] + else + id = matches[2] end - local id = msg.text:match('twitter.com/[^/]+/statuse?s?/([0-9]+)') local twitter_url = "https://api.twitter.com/1.1/statuses/show/" .. id.. ".json" local response_code, response_headers, response_status_line, response_body = client:PerformRequest("GET", twitter_url)