added blacklist
This commit is contained in:
parent
d3439a0faf
commit
41c18ef046
21
bot/bot.lua
21
bot/bot.lua
@ -110,26 +110,33 @@ end
|
|||||||
function match_plugin(plugin, plugin_name, msg)
|
function match_plugin(plugin, plugin_name, msg)
|
||||||
local receiver = get_receiver(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
|
for k, pattern in pairs(plugin.patterns) do
|
||||||
local matches = match_pattern(pattern, msg.text)
|
local matches = match_pattern(pattern, msg.text)
|
||||||
if matches then
|
if matches then
|
||||||
print("msg matches: ", pattern)
|
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
|
return nil
|
||||||
end
|
end
|
||||||
-- Function exists
|
-- Function exists
|
||||||
if plugin.run then
|
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
|
if not warns_user_not_allowed(plugin, msg) then
|
||||||
local result = plugin.run(msg, matches)
|
local result = plugin.run(msg, matches)
|
||||||
if result then
|
if result then
|
||||||
send_large_msg(receiver, result)
|
send_large_msg(receiver, result)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
-- One patterns matches
|
end
|
||||||
|
-- One pattern matches
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -150,6 +150,17 @@ function is_sudo(msg)
|
|||||||
return var
|
return var
|
||||||
end
|
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
|
-- Returns the name of the sender
|
||||||
function get_name(msg)
|
function get_name(msg)
|
||||||
local name = msg.from.first_name
|
local name = msg.from.first_name
|
||||||
|
Reference in New Issue
Block a user