From c37ad5a1566faf34c962dab4954991a04a60be1a Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Thu, 8 Sep 2016 00:28:20 +0200 Subject: [PATCH] - Setze HTTP-Timeout korrekt - convert_timestamp nutzt nun os.date() --- otouto/bindings.lua | 2 +- otouto/bot.lua | 1 - otouto/utilities.lua | 10 ++++------ 3 files changed, 5 insertions(+), 8 deletions(-) diff --git a/otouto/bindings.lua b/otouto/bindings.lua index 40d0d7f..5f7afbe 100644 --- a/otouto/bindings.lua +++ b/otouto/bindings.lua @@ -23,7 +23,7 @@ local bindings = {} local https = require('ssl.https') -https.timeout = 10 +https.TIMEOUT = 10 local json = require('dkjson') local ltn12 = require('ltn12') local mp_encode = require('multipart-post').encode diff --git a/otouto/bot.lua b/otouto/bot.lua index a512d9c..b66c104 100644 --- a/otouto/bot.lua +++ b/otouto/bot.lua @@ -62,7 +62,6 @@ end function bot:on_msg_receive(msg, config) -- The fn run whenever a message is received. -- remove comment to enable debugging -- vardump(msg) - -- Cache user info for those involved. if msg.date < os.time() - 5 then return end -- Do not process old messages. diff --git a/otouto/utilities.lua b/otouto/utilities.lua index 733e0d3..a46b418 100644 --- a/otouto/utilities.lua +++ b/otouto/utilities.lua @@ -34,8 +34,8 @@ mime = (loadfile "./otouto/mimetype.lua")() OAuth = require "OAuth" helpers = require "OAuth.helpers" -http.timeout = 5 -https.timeout = 5 +http.TIMEOUT = 7 +https.TIMEOUT = 7 -- For the sake of ease to new contributors and familiarity to old contributors, -- we'll provide a couple of aliases to real bindings here. @@ -387,10 +387,8 @@ function run_command(str) return result end -function convert_timestamp(timestamp, format) - local converted_date = run_command('date -d @'..timestamp..' +"'..format..'"') - local converted_date = string.gsub(converted_date, '%\n', '') - return converted_date +function convert_timestamp(timestamp, date_format) + return os.date(date_format, timestamp) end function string.starts(String, Start)