From 8f392538ee53bbd74075d1e464e05f80fc3af653 Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Wed, 7 Dec 2016 22:37:07 +0100 Subject: [PATCH 1/4] =?UTF-8?q?Stelle=20Timeout=20zur=C3=BCck,=20vielleich?= =?UTF-8?q?t=20fixt=20es=20ja,=20dass=20der=20Bot=20nicht=20auf=20einige?= =?UTF-8?q?=20Nachrichten=20antwortet?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- otouto/bot.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/otouto/bot.lua b/otouto/bot.lua index 66ab992..6a84d51 100644 --- a/otouto/bot.lua +++ b/otouto/bot.lua @@ -223,7 +223,7 @@ function bot:run(config) while self.is_started do -- 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 -- Iterate over every new message. for n=1, #res.result do @@ -408,4 +408,4 @@ function create_cred() print ('saved credentials into reds hash telegram:credentials') end -return bot \ No newline at end of file +return bot From 248ab78062532e827dae563082b3acf9bcd9c27e Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Tue, 10 Jan 2017 23:53:16 +0100 Subject: [PATCH 2/4] fixes --- otouto/plugins/gImages.lua | 14 +++++--------- otouto/plugins/respond.lua | 7 ++++--- 2 files changed, 9 insertions(+), 12 deletions(-) diff --git a/otouto/plugins/gImages.lua b/otouto/plugins/gImages.lua index cd166ea..7634e33 100644 --- a/otouto/plugins/gImages.lua +++ b/otouto/plugins/gImages.lua @@ -43,19 +43,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 jstr, res = https.request(url) local jdat = json.decode(jstr).items - + + if res == 403 then + return 403 + end + if not jdat then return 'NORESULTS' end - if jdat.error then - if jdat.error.code == 403 then - return 403 - else - return false - end - end - return jdat end diff --git a/otouto/plugins/respond.lua b/otouto/plugins/respond.lua index 887432c..4a39be5 100644 --- a/otouto/plugins/respond.lua +++ b/otouto/plugins/respond.lua @@ -2,13 +2,14 @@ local respond = {} function respond:init(config) 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][Rr])", "([Ee][Ii][Nn][Zz][Ii][Gg][Ss][Tt][Ee])", "^[Bb][Oo][Tt]%??$", "^/([Ll][Oo][Dd])$", - "^/([Ll][Ff])$", + "/([Ll][Ff])", "^/([Kk][Aa])$", "^/([Ii][Dd][Kk])$", "^/([Nn][Bb][Cc])$", @@ -71,7 +72,7 @@ function respond:action(msg, config, matches) elseif string.match(msg.text, "[Ll][Ff]") then utilities.send_message(receiver, '( ͡° ͜ʖ ͡°)') 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, [[¯\_(ツ)_/¯]]) return elseif string.match(msg.text, "[Ff][Rr][Oo][Ss][Cc][Hh]") then From 6e211474c96d75a878c2cf15991828789047bdf3 Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Sat, 14 Jan 2017 14:25:00 +0100 Subject: [PATCH 3/4] Fixe Amazon-Plugin mit einigen URLs (warum hat Amazon so verdammt viele verschiedene Produkt-URLs?) --- otouto/plugins/amazon_cleaner.lua | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/otouto/plugins/amazon_cleaner.lua b/otouto/plugins/amazon_cleaner.lua index 52080fb..a6a4f7d 100644 --- a/otouto/plugins/amazon_cleaner.lua +++ b/otouto/plugins/amazon_cleaner.lua @@ -19,7 +19,12 @@ function cln_amzn:action(msg, config, matches) local ok, response_code, response_headers = http.request(request_constructor) 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) return end From 079592ad831cd7a5fdddd91e05d4ca64fb9a643a Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Sat, 14 Jan 2017 14:29:05 +0100 Subject: [PATCH 4/4] Fixe Wikipedia-Mobile-Links --- otouto/plugins/wikipedia.lua | 1 + 1 file changed, 1 insertion(+) diff --git a/otouto/plugins/wikipedia.lua b/otouto/plugins/wikipedia.lua index 1582464..5a1cd67 100644 --- a/otouto/plugins/wikipedia.lua +++ b/otouto/plugins/wikipedia.lua @@ -8,6 +8,7 @@ function wikipedia:init(config) "^/[Ww]iki (search) ?(.*)$", "^/[Ww]iki(%w+) (.+)$", "^/[Ww]iki ?(.*)$", + "(%w+).m.wikipedia.org/wiki/(.+)", "(%w+).wikipedia.org/wiki/(.+)" } wikipedia.inline_triggers = {