added blacklist

This commit is contained in:
Akamaru 2015-05-03 13:51:33 +02:00
parent d3439a0faf
commit 41c18ef046
2 changed files with 25 additions and 7 deletions

View File

@ -110,26 +110,33 @@ end
function match_plugin(plugin, plugin_name, msg)
local receiver = get_receiver(msg)
-- Go over patterns. If one matches is enought.
-- Go over patterns. If one matches is enough.
for k, pattern in pairs(plugin.patterns) do
local matches = match_pattern(pattern, msg.text)
if matches then
print("msg matches: ", pattern)
if is_plugin_disabled_on_chat(plugin_name, receiver) then
if is_plugin_disabled_on_chat(plugin_name, receiver) then
return nil
end
end
-- Function exists
if plugin.run then
-- If plugin is for privileged users only
-- check if user has privileges
if can_use_bot(msg) then
print("Gesperrt")
-- local text = 'Du darfst den Bot nicht nutzen!'
-- send_msg(receiver, text, ok_cb, false)
else
-- If plugin is for privileged users only
if not warns_user_not_allowed(plugin, msg) then
local result = plugin.run(msg, matches)
if result then
send_large_msg(receiver, result)
send_large_msg(receiver, result)
end
end
end
-- One patterns matches
end
-- One pattern matches
return
end
end

View File

@ -150,6 +150,17 @@ function is_sudo(msg)
return var
end
function can_use_bot(msg)
local var = false
-- Check users id in config
for v,user in pairs(_config.can_use_bot) do
if user == msg.from.id then
var = true
end
end
return var
end
-- Returns the name of the sender
function get_name(msg)
local name = msg.from.first_name