Merge Upstream

This commit is contained in:
Akamaru 2017-01-21 19:25:54 +01:00
commit cf794728c9
5 changed files with 18 additions and 15 deletions

View File

@ -226,7 +226,7 @@ function bot:run(config)
while self.is_started do while self.is_started do
-- Update loop -- Update loop
local res = bindings.getUpdates{ timeout = 120, offset = self.last_update+1, allowed_updates = {'message', 'inline_query', 'callback_query'} } local res = bindings.getUpdates{ timeout = 20, offset = self.last_update+1, allowed_updates = {'message', 'inline_query', 'callback_query'} }
if res then if res then
-- Iterate over every new message. -- Iterate over every new message.
for n=1, #res.result do for n=1, #res.result do
@ -496,4 +496,4 @@ function create_cred()
print ('Credentials gespeichert in telegram:credentials') print ('Credentials gespeichert in telegram:credentials')
end end
return bot return bot

View File

@ -19,7 +19,12 @@ function cln_amzn:action(msg, config, matches)
local ok, response_code, response_headers = http.request(request_constructor) local ok, response_code, response_headers = http.request(request_constructor)
local long_url = response_headers.location local long_url = response_headers.location
local domain, product_id = long_url:match('amazon.(%w+)/gp/product/(.+)/(.+)') if not long_url then return end
local domain, product_id = long_url:match('amazon.(%w+)/gp/product/(.+)/.+')
if not product_id then
domain, product_id = long_url:match('amazon.(%w+)/.+/dp/(.+)/')
end
if not product_id then return end
utilities.send_reply(msg, 'Ohne Ref: https://amazon.'..domain..'/dp/'..product_id) utilities.send_reply(msg, 'Ohne Ref: https://amazon.'..domain..'/dp/'..product_id)
return return
end end

View File

@ -46,19 +46,15 @@ function gImages:get_image(input)
local url = BASE_URL..'/?searchType=image&alt=json&num=10&key='..apikey..'&cx='..cseid..'&safe=high'..'&q=' .. input .. '&fields=items(link,mime,image(contextLink))' local url = BASE_URL..'/?searchType=image&alt=json&num=10&key='..apikey..'&cx='..cseid..'&safe=high'..'&q=' .. input .. '&fields=items(link,mime,image(contextLink))'
local jstr, res = https.request(url) local jstr, res = https.request(url)
local jdat = json.decode(jstr).items local jdat = json.decode(jstr).items
if res == 403 then
return 403
end
if not jdat then if not jdat then
return 'NORESULTS' return 'NORESULTS'
end end
if jdat.error then
if jdat.error.code == 403 then
return 403
else
return false
end
end
return jdat return jdat
end end

View File

@ -2,12 +2,13 @@ local respond = {}
function respond:init(config) function respond:init(config)
respond.triggers = { respond.triggers = {
"([Ff][Gg][Tt].? [Ss][Ww][Ii][Ff][Tt])", "/[Ss][Hh][Rr][Uu][Gg]",
"([Ff][Gg][Tt].? [Ss][Ww][Ii][Ff][Tt])",
"([Ee][Ii][Nn][Zz][Ii][Gg][Ss][Tt][Ee][Ss])", "([Ee][Ii][Nn][Zz][Ii][Gg][Ss][Tt][Ee][Ss])",
"([Ee][Ii][Nn][Zz][Ii][Gg][Ss][Tt][Ee][Rr])", "([Ee][Ii][Nn][Zz][Ii][Gg][Ss][Tt][Ee][Rr])",
"([Ee][Ii][Nn][Zz][Ii][Gg][Ss][Tt][Ee])", "([Ee][Ii][Nn][Zz][Ii][Gg][Ss][Tt][Ee])",
"^/([Ll][Oo][Dd])$", "^/([Ll][Oo][Dd])$",
"^/([Ll][Ff])$", "/([Ll][Ff])",
"^/([Kk][Aa])$", "^/([Kk][Aa])$",
"^/([Ii][Dd][Kk])$", "^/([Ii][Dd][Kk])$",
"^/([Nn][Bb][Cc])$", "^/([Nn][Bb][Cc])$",
@ -67,7 +68,7 @@ function respond:action(msg, config, matches)
elseif string.match(msg.text, "[Ll][Ff]") then elseif string.match(msg.text, "[Ll][Ff]") then
utilities.send_message(receiver, '( ͡° ͜ʖ ͡°)') utilities.send_message(receiver, '( ͡° ͜ʖ ͡°)')
return return
elseif string.match(msg.text, "[Nn][Bb][Cc]") or string.match(msg.text, "[Ii][Dd][Cc]") or string.match(msg.text, "[Kk][Aa]") or string.match(msg.text, "[Ii][Dd][Kk]") then elseif string.match(msg.text, "[Nn][Bb][Cc]") or string.match(msg.text, "[Ii][Dd][Cc]") or string.match(msg.text, "[Kk][Aa]") or string.match(msg.text, "[Ii][Dd][Kk]") or string.match(msg.text, "/[Ss][Hh][Rr][Uu][Gg]") then
utilities.send_message(receiver, [[¯\_(ツ)_/¯]]) utilities.send_message(receiver, [[¯\_(ツ)_/¯]])
return return
elseif string.match(msg.text, "[Ff][Rr][Oo][Ss][Cc][Hh]") then elseif string.match(msg.text, "[Ff][Rr][Oo][Ss][Cc][Hh]") then

View File

@ -8,6 +8,7 @@ function wikipedia:init(config)
"^/[Ww]iki (search) ?(.*)$", "^/[Ww]iki (search) ?(.*)$",
"^/[Ww]iki(%w+) (.+)$", "^/[Ww]iki(%w+) (.+)$",
"^/[Ww]iki ?(.*)$", "^/[Ww]iki ?(.*)$",
"(%w+).m.wikipedia.org/wiki/(.+)",
"(%w+).wikipedia.org/wiki/(.+)" "(%w+).wikipedia.org/wiki/(.+)"
} }
wikipedia.inline_triggers = { wikipedia.inline_triggers = {