--[[ cmd_mass.lua v0.08 by blastbeat - this script adds a command "mass" to send a pm mass message - usage: [+!#]mass - changelog 0.08: - updated script api - regged hubcommand - changelog 0.07: - mass will be send by hub bot now - fixed 'sends first word only' bug - changelog 0.06: - some clean ups - changelog 0.05: - added language files and ucmd - changelog 0.04: - updated script api ]]-- --// settings begin //-- local scriptname = "cmd_mass" local scriptlang = cfg.get "language" local minlevel = 30 local permission = { -- who is allowed to use this command? [ 0 ] = false, -- unreg [ 10 ] = false, -- guest [ 20 ] = false, -- reg [ 30 ] = true, -- vip [ 40 ] = true, -- svip [ 60 ] = true, -- operator [ 80 ] = true, -- admin [ 100 ] = true, -- hubowner } local cmd = "mass" --// settings end //-- local utf_match = utf.match local lang, err = cfg.loadlanguage( scriptlang, scriptname ); lang = lang or { }; err = err and hub.debug( err ) local help_title = lang.help_title or "mass" local help_usage = lang.help_usage or "[+!#]mass " local help_desc = lang.help_desc or "sends a pm with to all users" local ucmd_menu = lang.ucmd_menu or { "Mass message" } local ucmd_what = lang.ucmd_what or "Message:" local msg_denied = lang.msg_denied or "You are not allowed to use this command." local msg_usage = lang.msg_usage or "Usage: +mass " local hubcmd local onbmsg = function( user, command, msg ) msg = utf_match( msg, "(.+)" ) if not permission[ user:level( ) ] then user:reply( msg_denied, hub.getbot( ) ) return PROCESSED end if not msg then user:reply( msg_usage, hub.getbot( ) ) else hub.broadcast( msg, user, 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_what .. "]" }, { "CT1" }, minlevel ) end hubcmd = hub.import "etc_hubcommands" -- add hubcommand assert( hubcmd ) assert( hubcmd.add( cmd, onbmsg ) ) return nil end ) hub.debug( "** Loaded " .. scriptname .. ".lua **" )