    # File lib/rbot/core/auth.rb, line 445
      def auth_manage_user(m, params)
        splits = params[:data]

        cmd = splits.first
        return auth_whoami(m, params) if cmd.nil?

        botuser = get_botuser_for(m.source)
        # By default, we do stuff on the botuser the irc user is bound to
        butarget = botuser

        has_for = splits[-2] == "for"
        if has_for
          butarget = @bot.auth.get_botuser(splits[-1]) rescue nil
          return m.reply(_("no such bot user %{user}") % {:user => splits[-1]}) unless butarget
          splits.slice!(-2,2)
        end
        return m.reply(_("you can't mess with %{user}") % {:user => butarget.username}) if butarget.owner? && botuser != butarget

        bools = [:autologin, "login-by-mask""login-by-mask"]
        can_set = [:password]
        can_addrm = [:netmasks]
        can_reset = bools + can_set + can_addrm
        can_show = can_reset + ["perms"]

        begin
        case cmd.to_sym

        when :show
          return m.reply(_("you can't see the properties of %{user}") %
                 {:user => butarget.username}) if botuser != butarget &&
                                                   !botuser.permit?("auth::show::other")

          case splits[1]
          when nil, "all"
            props = can_reset
          when "password"
            if botuser != butarget
              return m.reply(_("no way I'm telling you the master password!")) if butarget == @bot.auth.botowner
              return m.reply(_("you can't ask for someone else's password"))
            end
            return m.reply(_("c'mon, you can't be asking me seriously to tell you the password in public!")) if m.public?
            return m.reply(_("the password for %{user} is %{password}") %
              { :user => butarget.username, :password => butarget.password })
          else
            props = splits[1..-1]
          end

          str = []

          props.each { |arg|
            k = arg.to_sym
            next if k == :password
            case k
            when *bools
              if ask_bool_prop(butarget, k)
                str << _("can %{action}") % {:action => k}
              else
                str << _("can not %{action}") % {:action => k}
              end
            when :netmasks
              if butarget.netmasks.empty?
                str << _("knows no netmasks")
              else
                str << _("knows %{netmasks}") % {:netmasks => butarget.netmasks.join(", ")}
              end
            end
          }
          return m.reply("#{butarget.username} #{str.join('; ')}")

        when :enable, :disable
          return m.reply(_("you can't change the default user")) if butarget.default? && !botuser.permit?("auth::edit::other::default")
          return m.reply(_("you can't edit %{user}") % {:user => butarget.username}) if butarget != botuser && !botuser.permit?("auth::edit::other")

          return m.reply(need_args(cmd)) unless splits[1]
          things = []
          skipped = []
          splits[1..-1].each { |a|
            arg = a.to_sym
            if bools.include?(arg)
              set_prop(butarget, arg, cmd.to_sym == :enable)
              things << a
            else
              skipped << a
            end
          }

          m.reply(_("I ignored %{things} because %{reason}") % {
                    :things => skipped.join(', '),
                    :reason => not_args(cmd, *bools)}) unless skipped.empty?
          if things.empty?
            m.reply _("I haven't changed anything")
          else
            @bot.auth.set_changed
            return auth_manage_user(m, {:data => ["show"] + things + ["for", butarget.username] })
          end

        when :set
          return m.reply(_("you can't change the default user")) if
                 butarget.default? && !botuser.permit?("auth::edit::default")
          return m.reply(_("you can't edit %{user}") % {:user=>butarget.username}) if
                 butarget != botuser && !botuser.permit?("auth::edit::other")

          return m.reply(need_args(cmd)) unless splits[1]
          arg = splits[1].to_sym
          return m.reply(not_args(cmd, *can_set)) unless can_set.include?(arg)
          argarg = splits[2]
          return m.reply(need_args([cmd, splits[1]].join(" "))) unless argarg
          if arg == :password && m.public?
            return m.reply(_("is that a joke? setting the password in public?"))
          end
          set_prop(butarget, arg, argarg)
          @bot.auth.set_changed
          auth_manage_user(m, {:data => ["show", arg.to_s, "for", butarget.username] })

        when :reset
          return m.reply(_("you can't change the default user")) if
                 butarget.default? && !botuser.permit?("auth::edit::default")
          return m.reply(_("you can't edit %{user}") % {:user=>butarget.username}) if
                 butarget != botuser && !botuser.permit?("auth::edit::other")

          return m.reply(need_args(cmd)) unless splits[1]
          things = []
          skipped = []
          splits[1..-1].each { |a|
            arg = a.to_sym
            if can_reset.include?(arg)
              reset_prop(butarget, arg)
              things << a
            else
              skipped << a
            end
          }

          m.reply(_("I ignored %{things} because %{reason}") %
                    { :things => skipped.join(', '),
                      :reason => not_args(cmd, *can_reset)}) unless skipped.empty?
          if things.empty?
            m.reply _("I haven't changed anything")
          else
            @bot.auth.set_changed
            @bot.say(m.source, _("the password for %{user} is now %{password}") %
              {:user => butarget.username, :password => butarget.password}) if
              things.include?("password")
            return auth_manage_user(m, {:data => (["show"] + things - ["password"]) + ["for", butarget.username]})
          end

        when :add, :rm, :remove, :del, :delete
          return m.reply(_("you can't change the default user")) if
                 butarget.default? && !botuser.permit?("auth::edit::default")
          return m.reply(_("you can't edit %{user}") % {:user => butarget.username}) if
                 butarget != botuser && !botuser.permit?("auth::edit::other")

          arg = splits[1]
          if arg.nil? or arg !~ /netmasks?/ or splits[2].nil?
            return m.reply(_("I can only add/remove netmasks. See +help user add+ for more instructions"))
          end

          method = cmd.to_sym == :add ? :add_netmask : :delete_netmask

          failed = []

          splits[2..-1].each { |mask|
            begin
              butarget.send(method, mask.to_irc_netmask(:server => @bot.server))
            rescue => e
              debug "failed with #{e.message}"
              debug e.backtrace.join("\n")
              failed << mask
            end
          }
          m.reply "I failed to #{cmd} #{failed.join(', ')}" unless failed.empty?
          @bot.auth.set_changed
          return auth_manage_user(m, {:data => ["show", "netmasks", "for", butarget.username] })

        else
          m.reply _("sorry, I don't know how to %{request}") % {:request => m.message}
        end
        rescue => e
          m.reply _("couldn't %{cmd}: %{exception}") % {:cmd => cmd, :exception => e}
        end
      end