Skip to content
This repository was archived by the owner on Oct 14, 2018. It is now read-only.

Commit b86897d

Browse files
committed
Bot can't kick himself
1 parent 53b4bc2 commit b86897d

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

plugins/banhammer.lua

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,12 @@ end
1313
local function kick_user(user_id, chat_id)
1414
local chat = 'chat#id'..chat_id
1515
local user = 'user#id'..user_id
16-
chat_del_user(chat, user, ok_cb, true)
16+
17+
if user_id == tostring(our_id) then
18+
send_msg(chat, "I won't kick myself!", ok_cb, true)
19+
else
20+
chat_del_user(chat, user, ok_cb, true)
21+
end
1722
end
1823

1924
local function ban_user(user_id, chat_id)
@@ -65,7 +70,7 @@ local function pre_process(msg)
6570
msg.text = ''
6671
end
6772
end
68-
73+
6974
-- WHITELIST
7075
local hash = 'whitelist:enabled'
7176
local whitelist = redis:get(hash)
@@ -95,7 +100,7 @@ local function pre_process(msg)
95100
msg.text = ''
96101
end
97102

98-
else
103+
else
99104
print('Whitelist not enabled or is sudo')
100105
end
101106

@@ -183,7 +188,7 @@ local function run(msg, matches)
183188
end
184189

185190
return {
186-
description = "Plugin to manage bans, kicks and white/black lists.",
191+
description = "Plugin to manage bans, kicks and white/black lists.",
187192
usage = {
188193
"!whitelist <enable>/<disable>: Enable or disable whitelist mode",
189194
"!whitelist user <user_id>: Allow user to use the bot when whitelist mode is enabled",
@@ -205,7 +210,7 @@ return {
205210
"^!(ban) (delete) (%d+)$",
206211
"^!(kick) (%d+)$",
207212
"^!!tgservice (.+)$",
208-
},
213+
},
209214
run = run,
210215
pre_process = pre_process
211216
}

0 commit comments

Comments
 (0)