/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
1 changed files with 15 additions and 5 deletions

View File

@ -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