Merge Upstream

This commit is contained in:
2016-10-02 18:57:39 +02:00
6 changed files with 160 additions and 21 deletions

View File

@ -31,16 +31,14 @@ function expand:inline_callback(inline_query, config, matches)
end
function expand:url(long_url)
local response_body = {}
local request_constructor = {
url = long_url,
method = "HEAD",
sink = ltn12.sink.table(response_body),
headers = {},
sink = ltn12.sink.null(),
redirect = false
}
local ok, response_code, response_headers, response_status_line = http.request(request_constructor)
local ok, response_code, response_headers = http.request(request_constructor)
return ok, response_headers
end

View File

@ -47,11 +47,11 @@ end
function gh_feed_check_modified(repo, cur_etag, last_date)
local url = BASE_URL..'/'..repo
local response_body = {}
local request_constructor = {
url = url,
method = "HEAD",
redirect = false,
sink = ltn12.sink.null(),
headers = {
Authorization = 'token '..token,
["If-None-Match"] = cur_etag

View File

@ -74,7 +74,7 @@ function notify:action(msg, config, matches)
redis:hset(hash, 'notify', false)
print('Lösche '..username..' von redis set notify:ls')
redis:srem('notify:ls', username)
utilities.send_reply(msg, 'Du erhälst jetzt keine Benachrichtigungen mehr, wenn du angesprochen wirst.')
utilities.send_reply(msg, 'Du erhältst jetzt keine Benachrichtigungen mehr, wenn du angesprochen wirst.')
return
else
if redis:sismember('notify:ls', username) then
@ -87,11 +87,11 @@ function notify:action(msg, config, matches)
redis:hset(hash, 'id', msg.from.id)
print('Adde '..username..' zu redis set notify:ls')
redis:sadd('notify:ls', username)
local res = utilities.send_message(msg.from.id, 'Du erhälst jetzt Benachrichtigungen, wenn du angesprochen wirst, nutze `/notify del` zum Deaktivieren.', true, nil, true)
local res = utilities.send_message(msg.from.id, 'Du erhältst jetzt Benachrichtigungen, wenn du angesprochen wirst, nutze `/notify del` zum Deaktivieren.', true, nil, true)
if not res then
utilities.send_reply(msg, 'Bitte schreibe mir [privat](http://telegram.me/' .. self.info.username .. '?start=notify), um den Vorgang abzuschließen.', true)
elseif msg.chat.type ~= 'private' then
utilities.send_reply(msg, 'Du erhälst jetzt Benachrichtigungen, wenn du angesprochen wirst, nutze `/notify del` zum Deaktivieren.', true)
utilities.send_reply(msg, 'Du erhältst jetzt Benachrichtigungen, wenn du angesprochen wirst, nutze `/notify del` zum Deaktivieren.', true)
end
end
end

View File

@ -40,18 +40,7 @@ local client = OAuth.new(consumer_key, consumer_secret, {
OAuthTokenSecret = access_token_secret
})
function twitter:action(msg, config, matches)
if not matches[2] then
id = matches[1]
else
id = matches[2]
end
local twitter_url = "https://api.twitter.com/1.1/statuses/show/" .. id.. ".json"
local get_params = {tweet_mode = 'extended'}
local response_code, response_headers, response_status_line, response_body = client:PerformRequest("GET", twitter_url, get_params)
local response = json.decode(response_body)
function get_tweet(response)
local full_name = response.user.name
local user_name = response.user.screen_name
if response.user.verified then
@ -149,8 +138,30 @@ function twitter:action(msg, config, matches)
text = text..'\n\n'..quote..'\n'
end
return header.."\n"..utilities.trim(text).."\n"..footer, images, videos
end
function twitter:action(msg, config, matches)
utilities.send_typing(msg.chat.id, 'typing')
if not matches[2] then
id = matches[1]
else
id = matches[2]
end
local twitter_url = "https://api.twitter.com/1.1/statuses/show/" .. id.. ".json"
local get_params = {tweet_mode = 'extended'}
local response_code, response_headers, response_status_line, response_body = client:PerformRequest("GET", twitter_url, get_params)
if response_code ~= 200 then
utilities.send_repl(msg, 'Twitter nicht erreichbar, Tweet existiert nicht oder User ist privat.')
return
end
local response = json.decode(response_body)
local text, images, videos = get_tweet(response)
-- send the parts
utilities.send_reply(msg, header .. "\n" .. utilities.trim(text).."\n"..footer, 'HTML')
utilities.send_reply(msg, text, 'HTML')
for k, v in pairs(images) do
local file = download_to_file(v)
utilities.send_photo(msg.chat.id, file, nil, msg.message_id)