forked from yagop/telegram-bot
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathkickme.lua
37 lines (34 loc) · 894 Bytes
/
kickme.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
local function kick_user(user_id, chat_id)
local chat = 'chat#id'..chat_id
local user = 'user#id'..user_id
chat_del_user(chat, user, function (data, success, result)
if success ~= 1 then
send_msg(data.chat, 'Error while kicking user', ok_cb, nil)
end
end, {chat=chat, user=user})
end
local function run (msg, matches)
local user = msg.from.id
local chat = msg.to.id
if msg.to.type ~= 'chat' then
return "Not a chat group!"
elseif user == tostring(our_id) then
--[[ A robot must protect its own existence as long as such protection does
not conflict with the First or Second Laws. ]]--
return "I won't kick myself!"
elseif is_sudo(msg) then
return "I won't kick an admin!"
else
kick_user(user, chat)
end
end
return {
description = "Bot kicks user",
usage = {
"!kickme"
},
patterns = {
"^!kickme$"
},
run = run
}