--[[ cmd_nick.lua v0.02 by blastbeat - this script adds a command "nick" to change nick - usage: [+!#]nick - note: after changing your nick as regged user, you maybe have to login in again to get your old nick - note: in general this script maybe have some unexpected side effects; use with care =) - changelog 0.02: - updated script api ]]-- --// settings begin //-- local permission = { -- who is allowed to use this command? [ 0 ] = true, -- unreg [ 10 ] = true, -- guest [ 20 ] = true, -- reg [ 30 ] = true, -- vip [ 40 ] = true, -- svip [ 60 ] = true, -- operator [ 80 ] = true, -- admin [ 100 ] = true, -- hubowner } local nick_change = cfg.get "nick_change" -- nick change allowed? local msg_denied = "Changing nick is not allowed here." local msg_usage = "Usage: +nick " local msg_error = "An error occured: " local msg_ok = "Your nick was changed to: " local cmd = "nick" --// settings end //-- local utf_match = utf.match hub:setListener( "onStart", { }, function( ) local help = hub.import "cmd_help" if help then help.reg( "nick", "[+!#]nick ", "changes your nick to ", 0 ) end return nil end ) hub:setListener( "onBroadcast", { }, function( user, adccmd, txt ) local command, parameters = utf_match( txt, "^[+!#](%a+) ?(.*)" ) if command == cmd then if not nick_change then user:reply( msg_denied, hub.getbot( ) ) return PROCESSED end local new_nick = hub.escapeto( parameters ) if not new_nick then user:reply( msg_usage, hub.getbot( ) ) return PROCESSED end local bol, err = user:updateNick( new_nick ) if bol then user:reply( msg_ok .. new_nick, hub.getbot( ) ) if user:isRegged( ) then --p.user:setRegNick( new_nick ) -- this doesnt work as expected at the moment end else user:reply( msg_error .. ( err or "" ), hub.getbot( ) ) end return PROCESSED end return nil end ) hub.debug( "** Loaded cmd_nick.lua **" )