Code: Select all
-- cmd_report.lua v0.1 by ATAG
--// settings start //--
local scriptname = "cmd_report"
local scriptlang = cfg.get "language"
local minlevel = 0
local cmd = "report"
--// settings end //--
local opchat = hub.import "bot_opchat"
local utf_match = utf.match
local utf_format = utf.format
local lang, err = cfg.loadlanguage( scriptlang, scriptname ); lang = lang or { }; err = err and hub.debug( err )
local help_title = lang.help_title or "report"
local help_usage = lang.help_usage or "[+!#]report <who> <why>"
local help_desc = lang.help_desc or "report <who> to operators"
local ucmd_menu = lang.ucmd_menu or { "Report" }
local ucmd_who = lang.ucmd_who or "Who:"
local ucmd_why = lang.ucmd_why or "Why:"
local msg_denied = lang.msg_denied or "You are not allowed to use this command."
local msg_usage = lang.msg_usage or "Usage: +report <who> <why>"
local msg_reports = lang.msg_reports or "%s reports: %s"
local msg_sent = lang.msg_sent or "Your report has sent. Thank You"
local hubcmd
local onbmsg = function( user, command, msg )
msg = utf_match( msg, "(.+)" )
if user:level( ) < minlevel then
user:reply( msg_denied, hub.getbot( ) )
return PROCESSED
end
if not msg then
user:reply( msg_usage, hub.getbot( ) )
else
opchat.feed( utf_format( msg_reports, user:nick( ), msg ) )
user:reply( msg_sent, hub.getbot( ) )
end
return PROCESSED -- dont send cmd to hub and other scripts
end
hub.setlistener( "onStart", { },
function( )
local help = hub.import "cmd_help"
if help then
help.reg( help_title, help_usage, help_desc, minlevel ) -- reg help
end
local ucmd = hub.import "etc_usercommands" -- add usercommand
if ucmd then
ucmd.add( ucmd_menu, cmd, { "%[line:" .. ucmd_who .. "]", "%[line:" .. ucmd_why .. "]" }, { "CT1" }, minlevel )
ucmd.add( ucmd_menu, cmd, { "%[userNI]", " %[line:" .. ucmd_why .. "]" }, { "CT2" }, minlevel )
end
hubcmd = hub.import "etc_hubcommands" -- add hubcommand
assert( hubcmd )
assert( hubcmd.add( cmd, onbmsg ) )
return nil
end
)
hub.debug( "** Loaded " .. scriptname .. ".lua **" )