Skip to content

Commit

Permalink
Bot can't kick himself
Browse files Browse the repository at this point in the history
  • Loading branch information
yagop committed Nov 1, 2015
1 parent 53b4bc2 commit b86897d
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions plugins/banhammer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ end
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, ok_cb, true)

if user_id == tostring(our_id) then
send_msg(chat, "I won't kick myself!", ok_cb, true)
else
chat_del_user(chat, user, ok_cb, true)
end
end

local function ban_user(user_id, chat_id)
Expand Down Expand Up @@ -65,7 +70,7 @@ local function pre_process(msg)
msg.text = ''
end
end

-- WHITELIST
local hash = 'whitelist:enabled'
local whitelist = redis:get(hash)
Expand Down Expand Up @@ -95,7 +100,7 @@ local function pre_process(msg)
msg.text = ''
end

else
else
print('Whitelist not enabled or is sudo')
end

Expand Down Expand Up @@ -183,7 +188,7 @@ local function run(msg, matches)
end

return {
description = "Plugin to manage bans, kicks and white/black lists.",
description = "Plugin to manage bans, kicks and white/black lists.",
usage = {
"!whitelist <enable>/<disable>: Enable or disable whitelist mode",
"!whitelist user <user_id>: Allow user to use the bot when whitelist mode is enabled",
Expand All @@ -205,7 +210,7 @@ return {
"^!(ban) (delete) (%d+)$",
"^!(kick) (%d+)$",
"^!!tgservice (.+)$",
},
},
run = run,
pre_process = pre_process
}

0 comments on commit b86897d

Please sign in to comment.