From 80f988949ad2f8819ee36c037682fcf5b134825d Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Wed, 7 Sep 2016 23:40:50 +0200 Subject: [PATCH 1/3] GitHub: Nutze HTML und Autornamen, statt Committer --- otouto/plugins/github.lua | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/otouto/plugins/github.lua b/otouto/plugins/github.lua index 80432d4..83eb754 100644 --- a/otouto/plugins/github.lua +++ b/otouto/plugins/github.lua @@ -23,9 +23,9 @@ end function github:send_github_data(data) if not data.owner then return nil end - local name = '*'..utilities.md_escape(data.name)..'*' - local description = '_'..utilities.md_escape(data.description)..'_' - local owner = utilities.md_escape(data.owner.login) + local name = ''..data.name..'' + local description = ''..data.description..'' + local owner = data.owner.login local clone_url = data.clone_url if data.language == nil or data.language == "" then language = '' @@ -40,17 +40,17 @@ function github:send_github_data(data) if data.homepage == nil or data.homepage == "" then homepage = '' else - homepage = '\n[Homepage besuchen]('..data.homepage..')' + homepage = '\nHomepage besuchen' end - local text = name..' von '..owner..'\n'..description..'\n`git clone '..clone_url..'`'..language..issues..homepage + local text = name..' von '..owner..'\n'..description..'\n
git clone '..clone_url..'
'..language..issues..homepage return text end function github:send_gh_commit_data(gh_code, gh_commit_sha, data) - if not data.committer then return nil end - local committer = data.committer.name + if not data.author then return nil end + local author = data.author.name local message = utilities.md_escape(data.message) - local text = '`'..gh_code..'@'..gh_commit_sha..'` von *'..committer..'*:\n'..message + local text = ''..gh_code..'@'..gh_commit_sha..' von '..author..':\n'..message return text end @@ -63,7 +63,7 @@ function github:action(msg, config, matches) else output = github:send_gh_commit_data(gh_code, gh_commit_sha, data) end - utilities.send_reply(msg, output, true) + utilities.send_reply(msg, output, 'HTML') end return github \ No newline at end of file From db120805acc8081e29fee0d1fd78d12d207f2119 Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Wed, 7 Sep 2016 23:51:44 +0200 Subject: [PATCH 2/3] =?UTF-8?q?/leave=20unterst=C3=BCtzt=20jetzt=20Paramet?= =?UTF-8?q?er,=20um=20andere=20Gruppen=20zu=20verlassen=20(ID=20oder=20@Na?= =?UTF-8?q?me=20=C3=BCbergeben)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- otouto/plugins/banhammer.lua | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/otouto/plugins/banhammer.lua b/otouto/plugins/banhammer.lua index 05bbb8c..14c15e9 100644 --- a/otouto/plugins/banhammer.lua +++ b/otouto/plugins/banhammer.lua @@ -22,6 +22,8 @@ function banhammer:init(config) "^/(block) (delete)$", "^/(kick) (%d+)$", "^/(kick)$", + "^/(leave) (%-?%d+)", + "^/(leave) (@[A-Za-z0-9-_-]+)", "^/(leave)$" } banhammer.doc = [[* @@ -184,12 +186,20 @@ function banhammer:action(msg, config, matches) end if matches[1] == 'leave' then - if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then - bindings.request('leaveChat', { - chat_id = msg.chat.id - } ) - return + if matches[2] then + chat_id = matches[2] + else + chat_id = msg.chat.id end + local result = bindings.request('leaveChat', { + chat_id = chat_id + } ) + if matches[2] and result then + utilities.send_reply(msg, 'Chat verlassen!') + elseif matches[2] and not result then + utilities.send_reply(msg, 'Chat konnte nicht verlassen werden, ist die ID/der Name korrekt?') + end + return end if matches[1] == 'ban' then From c37ad5a1566faf34c962dab4954991a04a60be1a Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Thu, 8 Sep 2016 00:28:20 +0200 Subject: [PATCH 3/3] - 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)