From db120805acc8081e29fee0d1fd78d12d207f2119 Mon Sep 17 00:00:00 2001 From: Andreas Bielawski Date: Wed, 7 Sep 2016 23:51:44 +0200 Subject: [PATCH] =?UTF-8?q?/leave=20unterst=C3=BCtzt=20jetzt=20Parameter,?= =?UTF-8?q?=20um=20andere=20Gruppen=20zu=20verlassen=20(ID=20oder=20@Name?= =?UTF-8?q?=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