From a5d44d7a1532b21aacada00d05bc7fe3859d6c7a Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Sat, 27 Aug 2016 14:46:47 +0200 Subject: [PATCH] =?UTF-8?q?-=20Fixe=20ID=20-=20Post-Photo=20gibt=20msg=20b?= =?UTF-8?q?ei=20>=2020=20MB=20zur=C3=BCck=20-=20Keine=20Fehlermeldung=20me?= =?UTF-8?q?hr,=20wenn=20Seite=20keinen=20Header=20sendet=20(Media,=20Image?= =?UTF-8?q?s)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- otouto/plugins/id.lua | 4 ++-- otouto/plugins/post_photo.lua | 2 +- otouto/utilities.lua | 34 ++++++++++++++++++++-------------- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/otouto/plugins/id.lua b/otouto/plugins/id.lua index bc76888..f88b4e9 100644 --- a/otouto/plugins/id.lua +++ b/otouto/plugins/id.lua @@ -31,9 +31,9 @@ function id:user_print_name(user) -- Yes, copied from stats plugin local text = '' if user.first_name then - text = user.last_name..' ' + text = user.first_name..' ' end - if user.lastname then + if user.last_name then text = text..user.last_name end diff --git a/otouto/plugins/post_photo.lua b/otouto/plugins/post_photo.lua index 808d8ca..6d04cbb 100644 --- a/otouto/plugins/post_photo.lua +++ b/otouto/plugins/post_photo.lua @@ -17,7 +17,7 @@ function post_photo:pre_process(msg, config) local file_size = msg.document.file_size if file_size > 19922944 then print('File is over 20 MB - can\'t download :(') - return + return msg end utilities.send_typing(msg.chat.id, 'upload_photo') diff --git a/otouto/utilities.lua b/otouto/utilities.lua index b7effed..e53d786 100644 --- a/otouto/utilities.lua +++ b/otouto/utilities.lua @@ -947,22 +947,28 @@ function get_cached_file(url, file_name, receiver, chat_action) local header, code = get_http_header(url) -- file size limit is 50 MB - if header["Content-Length"] then - if tonumber(header["Content-Length"]) > 52420000 then - print('file is too large, won\'t send!') - return nil + if header then + + if header["Content-Length"] then + if tonumber(header["Content-Length"]) > 52420000 then + print('file is too large, won\'t send!') + return nil + end + elseif header["content-length"] then + if tonumber(header["content-length"]) > 52420000 then + print('file is too large, won\'t send!') + return nil + end end - elseif header["content-length"] then - if tonumber(header["content-length"]) > 52420000 then - print('file is too large, won\'t send!') - return nil - end - end - if header["last-modified"] then - last_modified = header["last-modified"] - elseif header["Last-Modified"] then - last_modified = header["Last-Modified"] + if header["last-modified"] then + last_modified = header["last-modified"] + elseif header["Last-Modified"] then + last_modified = header["Last-Modified"] + end + + else + last_modified = nil end if not last_modified then