--[[ cmd_setpas.lua v0.01 by blastbeat - this script adds a command "setpas" to set or change a password of an users by sid/nick/cid - usage: [+!#]setpas sid|nick|cid || - [+!#]setpas sets your own pasword ]]-- --// settings begin //-- local permission = { --// [ user_level = level means user_level can setpas of users with level max //-- [ 100 ] = 100, -- hubowner can set passwords of all } local feed = true -- send status message to opchat? local msg_denied = "You are not allowed to use this command." local msg_usage = "Usage: [+!#]setpas sid|nick|cid || " local msg_off = "User not found." local msg_god = "You cannot set passwords of gods." local msg_reg = "User is not regged or a bot." local msg_ok = "Password was changed to: " local cmd = "setpas" --// settings end //-- local utf_match = utf.match local hub_getbot = hub.getbot local hub_issidonline = hub.issidonline local hub_iscidonline = hub.iscidonline local hub_isnickonline = hub.isnickonline hub:setListener( "onStart", { }, function( ) local help = hub.import "cmd_help" if help then help.reg( "setpas", "[+!#]setpas sid|nick|cid || ", "sets password of user; [+!#]setpas sets your own pasword", 10 ) end return nil end ) hub:setListener( "onBroadcast", { }, function( user, adccmd, txt ) local command, parameters = utf_match( txt, "^[+!#](%a+) ?(.*)" ) if command == cmd then if not user:isRegged( ) then user:reply( msg_denied, hub_getbot( ) ) return PROCESSED end local level = user:getLevel( ) local pass1 = utf_match( parameters, "^(%S+)$" ) local by, id, pass2 = utf_match( parameters, "^(%S+) (%S+) (%S+)$" ) if not ( pass1 or ( pass2 and ( by == "sid" or by == "nick" or by == "cid" ) ) ) then user:reply( msg_usage, hub_getbot( ) ) return PROCESSED end local target = ( pass1 and user ) or ( by == "nick" and hub_isnickonline( id ) ) or ( by == "sid" and hub_issidonline( id ) ) or ( by == "cid" and hub_iscidonline( id ) ) if not target then user:reply( msg_off, hub_getbot( ) ) return PROCESSED end if not ( pass1 or target:isRegged( ) ) or target:isBot( ) then user:reply( msg_reg, hub_getbot( ) ) return PROCESSED end local pass = pass1 or pass2 if not pass1 and ( ( permission[ level ] or 0 ) < target:getLevel( ) ) then user:reply( msg_god, hub_getbot( ) ) return PROCESSED end target:setPas( pass ) user:reply( msg_ok .. pass, hub_getbot( ) ) local _ = not pass1 and target:reply( msg_ok .. pass, hub_getbot( ) ) return PROCESSED end return nil end ) hub.debug( "** Loaded cmd_setpas.lua **" )