/leave unterstützt jetzt Parameter, um andere Gruppen zu verlassen (ID oder @Name übergeben)

This commit is contained in:
Andreas Bielawski 2016-09-07 23:51:44 +02:00
parent 80f988949a
commit db120805ac

View File

@ -22,6 +22,8 @@ function banhammer:init(config)
"^/(block) (delete)$", "^/(block) (delete)$",
"^/(kick) (%d+)$", "^/(kick) (%d+)$",
"^/(kick)$", "^/(kick)$",
"^/(leave) (%-?%d+)",
"^/(leave) (@[A-Za-z0-9-_-]+)",
"^/(leave)$" "^/(leave)$"
} }
banhammer.doc = [[* banhammer.doc = [[*
@ -184,12 +186,20 @@ function banhammer:action(msg, config, matches)
end end
if matches[1] == 'leave' then if matches[1] == 'leave' then
if msg.chat.type == 'group' or msg.chat.type == 'supergroup' then if matches[2] then
bindings.request('leaveChat', { chat_id = matches[2]
chat_id = msg.chat.id else
} ) chat_id = msg.chat.id
return
end 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 end
if matches[1] == 'ban' then if matches[1] == 'ban' then