added blacklist
This commit is contained in:
parent
d3439a0faf
commit
41c18ef046
11
bot/bot.lua
11
bot/bot.lua
@ -110,7 +110,7 @@ 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
|
||||
@ -121,6 +121,12 @@ function match_plugin(plugin, plugin_name, msg)
|
||||
end
|
||||
-- Function exists
|
||||
if plugin.run then
|
||||
-- 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)
|
||||
@ -129,7 +135,8 @@ function match_plugin(plugin, plugin_name, msg)
|
||||
end
|
||||
end
|
||||
end
|
||||
-- One patterns matches
|
||||
end
|
||||
-- One pattern matches
|
||||
return
|
||||
end
|
||||
end
|
||||
|
@ -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
|
||||
|
Reference in New Issue
Block a user