Fixed tweet plugin: id match and return message
This commit is contained in:
parent
91edf21fcf
commit
69737edfd5
@ -125,7 +125,7 @@ end
|
|||||||
|
|
||||||
|
|
||||||
local function analyze_tweet(tweet)
|
local function analyze_tweet(tweet)
|
||||||
local header = "Tweet von " .. tweet.user.name .. " (@" .. tweet.user.screen_name .. ")\n" -- "Link: https://twitter.com/statuses/" .. tweet.id_str
|
local header = "Tweet von " .. tweet.user.name .. " (@" .. tweet.user.screen_name .. ")\nLink: https://twitter.com/statuses/" .. tweet.id_str .. "\n"
|
||||||
local text = tweet.text
|
local text = tweet.text
|
||||||
|
|
||||||
-- replace short URLs
|
-- replace short URLs
|
||||||
@ -147,6 +147,7 @@ local function analyze_tweet(tweet)
|
|||||||
table.insert(urls, v.media_url)
|
table.insert(urls, v.media_url)
|
||||||
end
|
end
|
||||||
text = text:gsub(v.url, "") -- Replace the URL in text
|
text = text:gsub(v.url, "") -- Replace the URL in text
|
||||||
|
text = unescape(text)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -157,6 +158,7 @@ end
|
|||||||
local function sendTweet(receiver, tweet)
|
local function sendTweet(receiver, tweet)
|
||||||
local header, text, urls = analyze_tweet(tweet)
|
local header, text, urls = analyze_tweet(tweet)
|
||||||
-- send the parts
|
-- send the parts
|
||||||
|
local text = unescape(text)
|
||||||
send_msg(receiver, header .. "\n" .. text, ok_cb, false)
|
send_msg(receiver, header .. "\n" .. text, ok_cb, false)
|
||||||
send_all_files(receiver, urls)
|
send_all_files(receiver, urls)
|
||||||
return nil
|
return nil
|
||||||
@ -189,6 +191,9 @@ local function getTweet(msg, base, all)
|
|||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function isint(n)
|
||||||
|
return n==math.floor(n)
|
||||||
|
end
|
||||||
|
|
||||||
local function run(msg, matches)
|
local function run(msg, matches)
|
||||||
local checked = check_keys()
|
local checked = check_keys()
|
||||||
@ -199,7 +204,11 @@ local function run(msg, matches)
|
|||||||
local base = {include_rts = 1}
|
local base = {include_rts = 1}
|
||||||
|
|
||||||
if matches[1] == 'id' then
|
if matches[1] == 'id' then
|
||||||
base.user_id = matches[2]
|
local userid = tonumber(matches[2])
|
||||||
|
if userid == nil or not isint(userid) then
|
||||||
|
return "The id of a user is a number, check this web: http://gettwitterid.com/"
|
||||||
|
end
|
||||||
|
base.user_id = userid
|
||||||
elseif matches[1] == 'name' then
|
elseif matches[1] == 'name' then
|
||||||
base.screen_name = matches[2]
|
base.screen_name = matches[2]
|
||||||
else
|
else
|
||||||
@ -221,9 +230,7 @@ local function run(msg, matches)
|
|||||||
end
|
end
|
||||||
base.count = count
|
base.count = count
|
||||||
|
|
||||||
getTweet(msg, base, all)
|
return getTweet(msg, base, all)
|
||||||
|
|
||||||
return nil
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user